Skip to content

fix(useTreeData): insert items into a child node with StrictMode#9824

Open
chirokas wants to merge 2 commits intoadobe:mainfrom
chirokas:tree-data-insert-child-node-strictmode
Open

fix(useTreeData): insert items into a child node with StrictMode#9824
chirokas wants to merge 2 commits intoadobe:mainfrom
chirokas:tree-data-insert-child-node-strictmode

Conversation

@chirokas
Copy link
Contributor

Closes

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@chirokas chirokas marked this pull request as ready for review March 22, 2026 09:06
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the PR, it'd be great if you could fill in the description. I realise this is a fairly simple one, but it'd be nice to know the original issue and how to reproduce it/how you are using it that results in this issue. Also, any information on how you diagnosed the issue and how you landed on this fix.

It can be easier if an issue is opened first. This gives us a place to discuss the problem and possible fixes. It really helps us evaluate PRs instead of making a bunch of guesses.

Again, thank you for the PR.

insert(parentKey: Key | null, index: number, ...values: T[]) {
setItems(({items, nodeMap: originalMap}) => {
let {items: newNodes, nodeMap: newMap} = buildTree(values, originalMap, parentKey);
let {items: newNodes, nodeMap: newMap} = buildTree(values, new Map(originalMap), parentKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the update function below also do this?

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.

2 participants