Skip to content

Commit e528a4c

Browse files
AKhodykinAleksandr Khodykinwuweiweiwu
authored
fix: scroll to search focused tree item (#756)
* Fix ignoreOneTreeUpdate in static search method * Apply suggestions from code review Co-authored-by: Aleksandr Khodykin <akhodykin@MacBook-Pro-Aleksandr.local> Co-authored-by: wei <hello@weiweiwu.me>
1 parent 9aeaf3d commit e528a4c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/react-sortable-tree.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ class ReactSortableTree extends Component {
194194

195195
instanceProps.searchQuery = nextProps.searchQuery;
196196
instanceProps.searchFocusOffset = nextProps.searchFocusOffset;
197-
newState.instanceProps = instanceProps;
198-
197+
newState.instanceProps = {...instanceProps, ...newState.instanceProps };
198+
199199
return newState;
200200
}
201201

@@ -313,7 +313,7 @@ class ReactSortableTree extends Component {
313313
return { searchMatches: [] };
314314
}
315315

316-
const newState = {};
316+
const newState = { instanceProps: {} };
317317

318318
// if onlyExpandSearchedNodes collapse the tree and search
319319
const { treeData: expandedTreeData, matches: searchMatches } = find({
@@ -333,7 +333,7 @@ class ReactSortableTree extends Component {
333333

334334
// Update the tree with data leaving all paths leading to matching nodes open
335335
if (expand) {
336-
newState.ignoreOneTreeUpdate = true; // Prevents infinite loop
336+
newState.instanceProps.ignoreOneTreeUpdate = true; // Prevents infinite loop
337337
onChange(expandedTreeData);
338338
}
339339

0 commit comments

Comments
 (0)