Cannot get correct scroll on last item
See original GitHub issueHi! I picked up Kent’s work on useCombobox and react-virtual and came up with this: https://codesandbox.io/s/epic-morse-jffe1.
Released an alpha for Downshift to fix some things, and now it should work, apart from this use case: highlighting from first item to last (using ArrowUp) is not bringing the item into view. Scroll somehow fails (unless I pass {align: 'start'} to the scroll function. However I don’t want to do that for all cases.
Last item is scrolled correctly when moving from second to last to last (using ArrowDown).
Any idea why I get this bad scroll in the use case above? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Can't scroll down to the last item in the ListView - Stack Overflow
Any idea what's causing this issue and how can i fix this ? Here's my getView method implemented in my custom class
Read more >List Box - not able to scroll to last item | MrExcel Message Board
I don't want the list box to be as long as the list - I'm fine with the user scrolling to find what...
Read more >Element.scrollTop - Web APIs | MDN
The Element.scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically.
Read more >Control scrolling in a CollectionView - .NET MAUI
When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed....
Read more >Element size and scrolling - The Modern JavaScript Tutorial
Setting scrollTop to 0 or a big value, such as 1e9 will make the element scroll to the very top/bottom respectively. Don't take...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think the problem is right inside the method calculating the next highlighted index, I also need to check if items.length is 0. Will fix and write a test in the PR already opened.
nit: you can use
onHighlightedIndexChange@kentcdodds so you don’t have to perform that check inside the onStateChange.Just pushed a fix for this. And better yet, it fixes some other edge cases with dynamic virtualization as well. Update your sandbox dep and you should be good to go 😃