-
Notifications
You must be signed in to change notification settings - Fork 304
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
feat(scrollbar): overscroll and hide_when_not_scrollable #965
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #965 +/- ##
=======================================
- Coverage 92.0% 91.6% -0.4%
=======================================
Files 61 61
Lines 15933 15764 -169
=======================================
- Hits 14660 14445 -215
- Misses 1273 1319 +46 ☔ View full report in Codecov by Sentry. |
f120786
to
be41770
Compare
be41770
to
6326d6e
Compare
@joshka interested in providing thoughts before adding tests? |
I support the development and encorporation of this feature! |
What's the status of this feature? Is there any way I can help out. Would love to get it merged |
Basically… is this the way we want to go forward? |
Apologies for not getting to this one sooner for review. Yes this looks good to progress on. Do you think it would be worth splitting the hide feature and overscroll functionality into separate PRs - the hide functionality seems pretty simple and easy to merge without much discussion, but the overscroll seems more complex and has a few things I'd like to consider. For both, I'd suggest introducing enums that clarify the behavior rather than bools. For overscroll, I think it's worth considering the behavior of preventing overscrolling, and not just the display. It might be nice to pull these out into a set of "when blah, then blah" statements that more meaningfully describes the behavior These would end up in the docs for the scrollbar and in the tests that help describe how it works. |
Hmm this doesn't seem to work for me when I try to use this in the project I'm working on (in the I think this is tied to the lack of "communication" between the |
The Scrollbar does not change the scrolling behaviour in any way. It only represents the scroll visually by displaying a scrollbar. The overscroll behaviour is currently represented on the scrollbar which is what this PR allows to configure. It simply allows the scrollbar to show the end is reached. Whatever the widget itself does. |
Hmm I'm not sure I follow entirely, but that might be okay. Can you give an example of a before-and-after of what this PR actually does? |
Oh yeah, your right. My brain is still thinking that the scroll position is actually controlling the scroll of the data of whatever element is involved and not just the display of the bar. |
Every widget by itself defines how scrolling works and This in itself describes the scroll mess-up of ratatui currently well: There is no common ground. Widgets define the scrolling behavior differently (mqttui mainly uses 3 different widgets and has workarounds to get them behave somewhat similarly) and the
Hiding the scrollbar when there is nothing to scroll is very pointless with the current overscroll behavior as its basic idea is to be always able to scroll when there is content. The only option not to scroll with the current overscroll behavior is when the content is 0 or 1 lines high. Then there is no last line which could be scrolled to. Yes, we could split this but the hide method on its own is pointless then.
I like thinking about it, but I'll postpone this because of my other points.
Here we are at widgets behaviour / scrollbar visualization point again (my first point). Widgets define how scrolling works and the scrollbar only tries to visualize it. The current Personal opinion: We need to have some shared idea of scrollable widgets (#174). Then we can ensure the widgets have a shared scrolling behavior. Only then we can visualize the scrolling behavior of the individual widgets consistently. Therefore, I think this PR is currently pointless until #174 advances. I would close it. |
After revisiting this with a better understanding of what this change does (and doesn't do), I'd love to see this merged! @EdJoPaTo, would you like help to implement the minor changes suggested? Or are you still not feeling great about it? |
It would improve the visual situation a little, but it would not solve this mix up and confusion around it (probably even increase it). There is a workaround (described in my first post) which I use for my applications. I think my suggested |
I think that improving the visual situation is an important first step. I came up with what I assume is a similar work-around: not changing the scroll value when it reaches the limit (based on the viewport size, content length, etc.) |
Personally I don't like the scrollbar to reflect the overscroll. This adds a setting to turn this off. (personal opinion: overscroll shouldn't be the default)
Also, there is often content without the need for scrolling (Like a List with fewer items than its height allows). I also added a setting to disable rendering in such a case.
There are no test cases for this yet as I would prefer to discuss this first before taking even more effort into this.
Workaround until there is a proper solution (like this PR attempts):
state.saturating_sub(viewport_content_length)
both hides the scrollbar without scroll and hides the overscroll.This PR will have merge conflicts with #963, and I will fix them after it's merged.DoneAccording to the code comment this change will definitely be a breaking change:
https://github.com/ratatui-org/ratatui/blob/d0067c8815d5244d319934d58a9366c8ad36b3e5/src/widgets/scrollbar.rs#L131