react-sortable-tree icon indicating copy to clipboard operation
react-sortable-tree copied to clipboard

Scrolling to matched node doesn't work when treeData changed

Open daniel-wer opened this issue 7 years ago • 0 comments

I'm using the searchQuery and searchFocusOffset props to highlight a specific node in my list and scroll to it. This mostly works as intended, however, every time the actual treeData changes, the scrolling doesn't work. See this example with a list and two buttons. Clicking one button adds an element to treeData - the scrolling to the highlighted node doesn't work. Clicking the other button causes a rerender of the list without changing treeData - the scrolling to the highlighted node works: https://codesandbox.io/s/74mxjrlvjx (Edit March, 4th 2021: The above link seems to have broken. I tried to replicate it here: https://codesandbox.io/s/sad-dream-g6x1n)

I've identified line 146 in react-sortable-tree.js as the cause of this issue. When treeData changes, this.search(nextProps, false, false) is called. Notice the seekIndex parameter is set to false - so no scrolling. Is this a bug or is there a reason why seekIndex is set to false in this case?

daniel-wer avatar May 15 '18 15:05 daniel-wer