Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollbar gets stuck in bottom after scrollable content becomes shorter #207

Open
andrewvarga opened this issue Nov 16, 2021 · 0 comments
Open

Comments

@andrewvarga
Copy link

Is your feature request related to a problem? Please describe.

Not sure if this is a bug report or a feature request, but I have a problem:

  • I have a vertically scrollable content
  • I go to the bottom of the scroll
  • then I remove some items from the content programatically so that the scrollable content is now smaller in height than the visible area (clientHeight) so there is nowhere to scroll to.

After this the scroll position is still at the bottom even though there is no content there, and so when I start scrolling up, the scrollbar gets smaller and eventually disappears.

Describe the solution you'd like

It would be good if this was caught automatically and the scrollbar would disappear if the content to be scroller becomes smaller.

Describe alternatives you've considered
I could detect if that happens in onUpdate but it feels like a hack:

let scrollTop = rect.scrollTop;
const extraThresholdToAvoidFlickering = 5;
const hasScrolledIntoEmptyBottomArea = rect.scrollHeight - extraThresholdToAvoidFlickering > rect.contentScrollHeight;
if (hasScrolledIntoEmptyBottomArea) {
   scrollTop = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant