-
Notifications
You must be signed in to change notification settings - Fork 944
Description
downshiftversion: latest
What you did:
Tried to combine useCombobox with react-virtual (though I expect this same problem would happen with any virtualization technique.
What happened:
Open up:
https://codesandbox.io/s/brave-einstein-vpvvo
Notice that if you focus the input and arrow down enough times, eventually the scrolling gets wacko.
I don't have a lot of time to explain, but hopefully the example helps you identify the issue.
The solution is to not get the node by the highlightedIndex alone, but by a unique identifier for the item.
So first, change itemRefs.current = [] to itemRefs.current = {}, then change this:
downshift/src/hooks/useCombobox/index.js
Line 316 in d2b273c
| itemRefs.current.push(itemNode) |
To this:
itemRefs.current[elementIds.current.getItemId(itemIndex)] = itemNodeAnd then update everywhere that references the itemRefs.current to retrieve the itemNode via the ID rather than the index. This fixes the bug for me.
Unfortunately, I have to move on and can't work on this myself right now. But hopefully that helps get anyone on the right track. Thanks and good luck!