You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: preserve pending collapse on parent hover - #220
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.
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.
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: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main fix: preserving pending collapse state during parent hover updates.
Linked Issues check
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
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
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
namespacearrays for child nodes.getDerivedStateFromPropscompares 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
shouldCollapsechanges so updated collapse rules continue to apply.Validation
pnpm testpasses all 216 tests using the existing React 16 and Enzyme setup.pnpm buildsucceeds.Summary by CodeRabbit