marchaos / react-virtualized-sticky-tree

A React component for efficiently rendering tree like structures with support for position: sticky
MIT License
151 stars 12 forks source link

Cannot read property 'top' of undefined #20

Closed JPNZ4 closed 4 years ago

JPNZ4 commented 4 years ago

Hey,

I have a sticky tree with a search/filter function at the top. When typing in the filter it will reduce the number of nodes that match the searched text. The list is displayed with an auto scroll as the number of nodes is a few thousand.

I get an error when I scroll to the bottom of the list and then type in my filter box at StickyTree.backwardSearch (StickyTree.js:1012).

In this method the search position comes in at the position the scroll was at before the list got filtered. However the node list in this function is the updated list with the amount of nodes that were filtered. The searchPosition is higher then the node list length and when it starts the loop, it will use an index that doesn't exist in the node array.

Ill try get a PR in today.

marchaos commented 4 years ago

Merged

DottieDot commented 4 years ago

The patch for this got removed in this commit. Shouldn't this be reopened again?