Skip to content

Commit d613ecd

Browse files
as666499lukasbach
andauthored
feat: #258 Loosing registered tree affecting drag and drop between different trees. (#439)
* 258: Using the updater function for setting new value for trees to avoid an issue in dragging items between trees. Drag and drop between trees was not working if the target tree was unmounted and mounted before the drag operation. * 258: updated release notes * fix: linter fix --------- Co-authored-by: Lukas Bach <contact@lukasbach.com>
1 parent f4512b0 commit d613ecd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎next-release-notes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### Features
55
66
### Bug Fixes and Improvements
7+
- Fixes an issue where drag and drop between trees was not working after remount of the target tree(#258)
78
89
### Other Changes
910
-->

‎packages/core/src/controlledEnvironment/useControlledTreeEnvironmentProps.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ export const useControlledTreeEnvironmentProps = ({
8888
const unregisterTree = useCallback(
8989
treeId => {
9090
onUnregisterTree?.(trees[treeId]);
91-
delete trees[treeId];
92-
setTrees(trees);
91+
setTrees(trees => {
92+
const newTrees = { ...trees };
93+
delete newTrees[treeId];
94+
return newTrees;
95+
});
9396
},
9497
[onUnregisterTree, trees]
9598
);

0 commit comments

Comments
 (0)