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