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

Add a well-documented way to prevent scrolling down when all lines are already within view #1017

Open
DeflateAwning opened this issue Apr 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@DeflateAwning
Copy link

DeflateAwning commented Apr 4, 2024

Problem

I don't want users to be able to scroll down when there are fewer lines showed on the screen than can fit on the screen.

For example:
image

In the example, there are only 9 lines of text in the middle block. About 20 lines will fit in the middle block. As such, the scrollbar should occupy the whole height of the entire Window, with the requested feature enabled.

Solution

I want a way to make the scrollbar basically full-height if all lines fit on the screen (i.e., there's nowhere to scroll). I'm not sure if this belongs within the ScrollbarState type or in the rest of the scrollbar styling/setup.

Alternatives

Maybe something exists? Haven't been able to find it or come up with it though.

Additional context

@DeflateAwning DeflateAwning added the enhancement New feature or request label Apr 4, 2024
@EdJoPaTo
Copy link
Member

EdJoPaTo commented Apr 4, 2024

#965 is an attempt of me to configure something like this but no one seemed to be interested enough to look into it so far (so I haven’t continued working on it).

my approach was to hide the scrollbar in that situation instead of showing it full height.

@joshka
Copy link
Member

joshka commented Apr 4, 2024

I'm definitely interested in having this as a feature (apologies of not getting to that review yet)
I'd like to see it designed out a bit so it makes sense to everyone that wants to use it.

@DeflateAwning
Copy link
Author

Would we want this to be the intended behaviour going forward, or should this be an option? My vote is for intended behaviour, as scrolling past the extents seems "cheap".

@joshka
Copy link
Member

joshka commented Apr 4, 2024

Both behaviors are valid. I thought the current over-scroll behavior was a bug when I first started to experiment with it, but it was an intentional approach (there also happened to be some extra complex code that made it difficult to see, which we fixed with a rewrite).

It's worth taking a quick (who am I kidding, long) read of the recent scrollbar PRs for context on this. I can't really summarize them - there's too much back and forth to do so.
https://github.com/ratatui-org/ratatui/pulls?q=is%3Apr+scrollbar+is%3Aclosed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants