Skip to content

Commit 2a1f74e

Browse files
committed
test
1 parent 3addcdb commit 2a1f74e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_compositor.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from textual.app import App, ComposeResult
2+
from textual.containers import Container
3+
from textual.widgets import Static
4+
5+
6+
async def test_compositor_scroll_placements():
7+
"""Regression test for https://github.com/Textualize/textual/issues/5249"""
8+
9+
class ScrollApp(App):
10+
CSS = """
11+
Screen {
12+
overflow: scroll;
13+
}
14+
Container {
15+
width: 200vw;
16+
}
17+
#hello {
18+
width: 20;
19+
height: 10;
20+
offset: 50 10;
21+
background: blue;
22+
color: white;
23+
}
24+
"""
25+
26+
def compose(self) -> ComposeResult:
27+
with Container():
28+
yield Static("Hello", id="hello")
29+
30+
def on_mount(self) -> None:
31+
self.query_one("Screen").scroll_to(20, 0, animate=False)
32+
33+
app = ScrollApp()
34+
async with app.run_test() as pilot:
35+
await pilot.pause()
36+
static = app.query_one("#hello")
37+
widgets = app.screen._compositor.visible_widgets
38+
# The static wasn't scrolled out of view, and should be visible
39+
assert static in widgets

0 commit comments

Comments
 (0)