-
Notifications
You must be signed in to change notification settings - Fork 815
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
Off-by-one error in data table height when a horizontal scrollbar is needed #3556
Comments
Gah, I missed #1289 when searching for this (I was only looking at open issues, not closed ones, since I was testing against |
Alright, I guess this is wontfix. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Actually - reopening this. #1289 (comment) suggests a workaround - setting the scrollbar to always visible. But, as far as I can tell, that doesn't actually work around the issue. I see the same problem even if I add: table.styles.overflow_x = "scroll" to the Am I doing something wrong? |
When the scrollbars appear they don't adjust the height of the widget. So when you get a horizontal bar it takes up one line of the widget, and forces a vertical scrollbar. The solution is In CSS: DataTable {
scrollbar-gutter: stable;
} You may be thinking why not adjust the auto height when a scrollbar is visible. And I did to, but that makes it impossible to create consistent layouts. And you can get in to a situation where a scrollbar pops in, forces a layout, which makes another scrollbar disappear, and forces another layout. And the whole UI flickers as a result. |
I tried |
Works for me. Can you share your code? |
Not at the moment, but I'll retest when I get a chance and get back to you. |
You're right, that works fine. Editing the class TableApp(App):
DEFAULT_CSS = """
DataTable {
scrollbar-gutter: stable;
}
"""
... does eliminate that vertical scrollbar. No idea what I did wrong the first time, but that's good enough for me! The docs should probably be fixed to indicate that Would you like a PR that basically just replaces "a vertical scrollbar" with "scrollbars" in those docs? |
A doc PR would be very welcome! |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
When the terminal is tall enough to display all rows of a DataTable, but not wide enough to display all columns, the table chooses a height for itself that's one row too short.
For example, try resizing your terminal to 45 columns by 24 rows, and then run
python docs/examples/widgets/data_table.py
, and you'll see something like:If you hit PageDn to scroll that, you'll see just one more line:
It seems like the data table is choosing to only use 10 lines out of the available 24 because it only has 10 rows worth of data to display, then it decides it needs a horizontal scrollbar, and suddenly it's got 10 rows of data and only 9 remaining rows to display them in, so it winds up adding a vertical scrollbar as well.
This seems unexpected to me. I don't think there should be a vertical scrollbar when the widget has plenty of room to grow vertically.
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: