Skip to content

fix: preserve pending collapse on parent hover - #220

Merged
Kikobeats merged 1 commit into
microlinkhq:masterfrom
Clarkkkk:master
Nov 5, 2026
Merged

Kikobeats merged 1 commit into
microlinkhq:masterfrom
Clarkkkk:master

Conversation

@Clarkkkk

@Clarkkkk Clarkkkk commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #216.

A parent hover update can overwrite a nested object's pending collapse in React 19, leaving it expanded after the first click.

Cause

Parent renders create fresh namespace arrays for child nodes. getDerivedStateFromProps compares these arrays by reference and treats an unchanged path as a prop change.

When hover and click updates are processed together, this recalculates expansion from the attribute store before the toggle's completion callback persists its value. The cached or initial value can overwrite the pending collapse.

Changes

  • Compare namespace segments and lengths instead of relying on array identity.
  • Explicitly track shouldCollapse changes so updated collapse rules continue to apply.
  • Add regression tests for batched hover/click updates on objects and arrays, path-specific cached state, and dynamic collapse rules.

Validation

  • pnpm test passes all 216 tests using the existing React 16 and Enzyme setup.
  • pnpm build succeeds.
  • A standalone React 19.3.1 production example using native Chrome input observed 29 failures in 30 fresh loads before the fix and 0 failures in 100 fresh loads after it.

Summary by CodeRabbit

  • Bug Fixes
    • Collapse behavior now updates when the collapse rule or namespace contents change, including when a namespace changes and later returns to an earlier state.
    • Recreating a namespace with the same entries no longer triggers an unnecessary state update.
    • Improved consistency when parent hover and child toggling happen together in object and array views.

@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

@Clarkkkk is attempting to deploy a commit to the Microlink Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Object state recomputation now responds to changes in shouldCollapse and namespace contents. Tests cover object and array branch toggles, state changes across namespaces, and collapse-rule updates.

Changes: Object collapse state

Layer / File(s) Summary
Recompute and verify collapse state
src/js/components/DataTypes/Object.js, test/tests/js/components/DataTypes/Object-test.js
State recomputation compares namespace entries and detects changes to shouldCollapse. Tests cover batched hover and toggle updates, state across namespace changes, and collapse-rule changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: xuefl-msft

Merge Risk: Minimal · up to 7b01c

The change addresses pending collapse updates and includes targeted regression tests. No actionable merge-blocking issue was identified; merge after normal checks pass.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main fix: preserving pending collapse state during parent hover updates.
Linked Issues check Passed Issue #216 requires preservation of a nested collapse during combined hover and click updates. getDerivedStateFromProps now compares namespace contents instead of fresh array identity and tracks `sh…
Out of Scope Changes check Passed The source change updates derived-state synchronization in RjvObject. The added tests directly cover the race, namespace cache behavior, and collapse-rule updates. No unrelated product behavior or u…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #216 requires preservation of a nested collapse during combined hover and click updates. getDerivedStateFromProps now compares namespace contents instead of fresh array identity and tracks shouldCollapse changes. The mounted regression tests cover object and array branches with unstable_batchedUpdates; they verify that a click removes the expanded content and that a second click restores it. Additional tests cover cached state by namespace and dynamic collapse rules.

Full details: Out of Scope Changes check

Explanation

The source change updates derived-state synchronization in RjvObject. The added tests directly cover the race, namespace cache behavior, and collapse-rule updates. No unrelated product behavior or unrelated files appear in the reviewed changes.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bb6a9104-d37d-4db0-a624-0348a749052e
Commits

Reviewing files that changed from the base of the PR and between b1c7028 and 7b01cba.

Files selected for processing: 2
  • src/js/components/DataTypes/Object.js
  • test/tests/js/components/DataTypes/Object-test.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-json-view Ready Ready Preview Nov 5, 2026 7:50am UTC

Request Review

@Kikobeats
Kikobeats merged commit 2068895 into microlinkhq:master Nov 5, 2026
2 checks passed

This branch was successfully deployed

1 active deployment
Preview — 7b01cba0 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First object collapse is overwritten by pending hover state in React 19 (standalone production repro)

2 participants