Extract reusable "descendant registry" pattern from ActionBar, with new support for reordering elements#7586
Merged
iansan5653 merged 2 commits intodescendant-registry-patternfrom Feb 24, 2026
Conversation
13 tasks
|
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Extract reusable descendant registry pattern from ActionBar
Extract reusable "descendant registry" pattern from Feb 23, 2026
ActionBar, with new support for reordering elements
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds unit tests for
createDescendantRegistryand fixes a bug where pure item reordering (no mounts/unmounts/value changes) failed to update the registry order.Changelog
New
createDescendantRegistrycovering: descendants inside wrapper components, React fragments, mid-list insertion, unmounting, reordering viakey, and deep-tree prependingChanged
createDescendantRegistryProvidernow detects whenchildrenreference changes without any descendant lifecycle events (the reorder case) and triggers a full rebuild, so the registry always reflects the current render orderRoot cause of the reorder bug: When items are reordered using React
keyprops (no remount), no child effects re-run because no hook dependencies change. ThecommitWorkingRegistryeffect was a no-op in theidlestate, so the registry stayed stale.Fix: Track
prevChildrenRefincommitWorkingRegistry. Whenchildrenchanges but no descendant fired aregister/unregister (i.e.,workingRegistryRefis still'idle'), queue a rebuild — this incrementskeyin context, causing all children to re-run their effects in the new DOM order.Removed
Rollout strategy
Testing & Reviewing
Six new tests in
packages/react/src/utils/__tests__/descendant-registry.test.tsx. Each test creates an isolated registry via acreateTestRegistry()factory to prevent cross-test context leakage.Merge checklist
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.