mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Ensure reflow reflows non-visible widgets, fix scroll_to_center issue (#2684)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,32 +5,33 @@ from textual.widgets import Label
|
||||
|
||||
class MyApp(App[None]):
|
||||
CSS = """
|
||||
VerticalScroll, HorizontalScroll {
|
||||
VerticalScroll {
|
||||
border: round $primary;
|
||||
}
|
||||
#vertical {
|
||||
height: 21;
|
||||
}
|
||||
HorizontalScroll {
|
||||
border: round $secondary;
|
||||
height: auto;
|
||||
}
|
||||
Label {
|
||||
height: auto;
|
||||
width: auto;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with VerticalScroll():
|
||||
yield Label(("SPAM\n" * 205)[:-1])
|
||||
with VerticalScroll():
|
||||
yield Label(("SPAM\n" * 53)[:-1])
|
||||
with VerticalScroll(id="vertical"):
|
||||
yield Label(("SPAM\n" * 78)[:-1])
|
||||
with HorizontalScroll():
|
||||
yield Label(("v\n" * 17)[:-1])
|
||||
yield Label("@" * 302)
|
||||
yield Label("[red]>>bullseye<<[/red]", id="bullseye")
|
||||
yield Label("@" * 99)
|
||||
yield Label(("SPAM\n" * 49)[:-1])
|
||||
yield Label(("SPAM\n" * 51)[:-1])
|
||||
yield Label(("SPAM\n" * 59)[:-1])
|
||||
yield Label(("SPAM\n" * 53)[:-1])
|
||||
with VerticalScroll(id="vertical"):
|
||||
yield Label(("SPAM\n" * 78)[:-1])
|
||||
with HorizontalScroll():
|
||||
yield Label(("v\n" * 17)[:-1])
|
||||
yield Label("@" * 302)
|
||||
yield Label("[red]>>bullseye<<[/red]", id="bullseye")
|
||||
yield Label("@" * 99)
|
||||
yield Label(("SPAM\n" * 49)[:-1])
|
||||
yield Label(("SPAM\n" * 51)[:-1])
|
||||
|
||||
def key_s(self) -> None:
|
||||
self.screen.scroll_to_center(self.query_one("#bullseye"))
|
||||
|
||||
@@ -518,9 +518,6 @@ def test_scroll_visible(snap_compare):
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "scroll_visible.py", press=["t"])
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
reason="Unpredictable while https://github.com/Textualize/textual/issues/2254 is open."
|
||||
)
|
||||
def test_scroll_to_center(snap_compare):
|
||||
# READ THIS IF THIS TEST FAILS:
|
||||
# While https://github.com/Textualize/textual/issues/2254 is open, the snapshot
|
||||
|
||||
Reference in New Issue
Block a user