-
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
Horizontal scroll bar disappeared in 0.87.1 #5284
Comments
One example of the test failing is: https://github.com/bloomberg/memray/blob/12cfcfe7c04280457d05725952b382447dbf4867/tests/unit/test_tui_reporter.py#L794 |
I can't think of anything off the top of my head that would cause this. What was the last known working version? |
I think this happened after #5000 |
0.81 |
The new textual release has some changes: * There are some changes that we need to do to get the rendered version of some textual objects as now render() returns RichVisual instances * Textual has a new theme so we need to regenerate our snapshots. * There is something going on with horizontal scroll bars. We have opened Textualize/textual#5284 but looks like this may be expected.
That release did unfortunately break snapshots, but I don't think that is the issue here. You have the following rule in your TCSS:
It looks like The rule makes the table 100% of the container. There are other things in the container, so the total height is greater than 100%, which forces the screen to scroll. If the table also has to scroll, then you would get the confusing double scrollbars. If you remove that rule, then it works more naturally. Maybe add a keybinding to maximize the table? |
Ah, the change here isn't whether or not the horizontal scrollbar is visible, it's the position of the vertical scrollbar, and how focusing widgets works. The horizontal scrollbar for the grid was never visible when the outermost vertical scrollbar was scrolled up, but we used to wake up with the AllocationTable focused and the outermost vertical scrollbar scrolled to the bottom: And now we wake up with that vertical scrollbar scrolled to the top instead: Bisecting tells me that this change came in e157c6b - you can reproduce for yourself with a memray run --live -c "import mmap; mmap.mmap(-1, 4096)" in a 80x24 terminal window. Moreover, pressing After e157c6b the first time you press |
The |
Quite possibly. The compose method is generally too early for UI updates. Could you set AUTO_FOCUS="AllocationTable" on your screen? |
That doesn't seem to work. I've added
to the TCSS to make it immediately obvious which widget is focused, and putting |
In fact, |
Any other suggestions, @willmcgugan? |
What appears to be happening is that the resize event is processed after the widget has been given focus. I'm not sure what the answer is to that ATM. A few options. In the meantime, you could use this workaround: Remove the call def on_show(self) -> None:
self.call_after_refresh(self.query_one("DataTable").focus) That should ensure that when the app runs in a narrow window, it will focus and scroll to it. |
Prior to e157c6b that seems to work 100% of the time, but after e157c6b that seems to sometimes work, and sometimes not. It seems to be racy... the widget always winds up focused, but it's only scrolled to about 75% of the time in my testing. Presumably it's still the same issue - the focus() call is sometimes happening before the data table has been resized to the height we want... |
And unfortunately it seems to work 100% of the time if I |
Here's my attempt at creating an MRE in case it helps someone... from textual import events
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Static
class Placeholder(Static, can_focus=True):
DEFAULT_CSS = """
Placeholder {
&:focus {
background: $success;
}
}
"""
class ExampleScreen(Screen):
def compose(self) -> ComposeResult:
yield Placeholder("Header", id="header")
yield Placeholder("Table", id="table")
def on_show(self) -> None:
self.call_after_refresh(self.query_one("#table").focus)
class ExampleApp(App):
CSS = """
#header {
height: 7;
}
.narrow #header {
height: 11;
}
#table {
height: 1fr;
}
.narrow #table {
height: 100%;
}
"""
def on_mount(self) -> None:
self.push_screen(ExampleScreen())
def on_resize(self, event: events.Resize) -> None:
self.set_class(0 <= event.size.width < 81, "narrow")
if __name__ == "__main__":
app = ExampleApp()
app.run() |
The App resize event is being sent after the auto focus. I'm working on a fix. A workaround, which won't require the |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I can confirm that #5296 fixes this for us. Thanks for the help! |
The new textual release has some changes: * We need to change how our tests get the rendered version of some Textual objects as now `render()` returns `RichVisual` instances. * Textual has a new theme so we need to regenerate our snapshots. * There was a regression in how focusing a widget while the app is still starting up behaves. This has been fixed upstream in Textualize/textual#5284 but our snapshots will not pass until the fix makes it into a release. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
We have a bunch of test failures due to textual in the 0.87.1 version. It seems that textual 0.87.1 has some regression that makes the horizontal scroll bar disappear. Here is some screenshots from our
BEFORE
AFTER
This also happens in the main
memray
app and makes impossible for users to scroll horizontally the table:The text was updated successfully, but these errors were encountered: