question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get correct scroll on last item

See original GitHub issue

Hi! 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:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
silviuaavramcommented, May 12, 2020

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.

1reaction
tannerlinsleycommented, May 12, 2020

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found