-
Notifications
You must be signed in to change notification settings - Fork 549
Fix unhydrated node parent tracking #24708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes unhydrated node parent tracking by centralizing the logic for updating parent pointers after every edit.
- Centralizes parent updates in the edit() method of UnhydratedFlexTreeField
- Updates tests to validate correct key and parent tracking for both insertions and removals
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/dds/tree/src/test/simple-tree/api/treeNodeApi.spec.ts | Updates tests with new hydration descriptions and behaviors for key and parent tracking |
packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts | Refactors parent updates by clearing and resetting adoptBy in the edit() method, and removes redundant adoptBy calls in removal blocks |
.changeset/eight-ears-feel.md | Documents the fix for Tree.key and Tree.parent for unhydrated nodes |
Comments suppressed due to low confidence (1)
packages/dds/tree/src/simple-tree/core/unhydratedFlexTree.ts:503
- Since the explicit adoptBy(undefined) call for removed nodes was removed in favor of centralized reset logic in the edit() method, please add a comment clarifying this change to improve maintainability.
const c = this.mapTrees[i];
Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs. The code changes seem reasonable to me, but I'm missing some context. Would probably be good to get a review from @noencke or someone too.
Description
Fix unhydrated node parent tracking by centralizing the logic to update parents, and applying it consistently after every edit.
This does make small edits in large sequences do O(N) parent updates, but they were already O(N) from modifying the large array, and need to do O(N) parent updates in the insertion is near the front anyway.
Reviewer Guidance
The review process is outlined on this wiki page.