From eadd487584bc15f1eba46324b2aaf4df0f8dffe4 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 6 Apr 2023 10:29:50 +0100 Subject: [PATCH] fix scroll issue --- CHANGELOG.md | 4 + src/textual/widget.py | 2 +- .../__snapshots__/test_snapshots.ambr | 156 ++++++++++++++++++ tests/snapshot_tests/test_snapshots.py | 5 + 4 files changed, 166 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 327036bb4..0d9655531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Allowed border_title and border_subtitle to accept Text objects - Added additional line around titles +### Fixed + +- Fixed issue which prevent scroll_visible from working https://github.com/Textualize/textual/issues/2181 + ## [0.18.0] - 2023-04-04 ### Added diff --git a/src/textual/widget.py b/src/textual/widget.py index fc5c8fb62..3c929ffd8 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -2238,7 +2238,7 @@ class Widget(DOMNode): parent = self.parent if isinstance(parent, Widget): self.call_after_refresh( - parent.scroll_to_widget, + self.screen.scroll_to_widget, self, animate=animate, speed=speed, diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 11b326d4f..40c652b8a 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -19516,6 +19516,162 @@ ''' # --- +# name: test_scroll_visible + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MyApp + + + + + + + + + + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + | + |▆▆ + | + | + | + | + CAN'T GET HERE + + + + + ''' +# --- # name: test_scrollbar_thumb_height ''' diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 7515a9ac0..deafb4a7c 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -386,3 +386,8 @@ def test_modal_dialog_bindings(snap_compare): def test_dock_scroll(snap_compare): # https://github.com/Textualize/textual/issues/2188 assert snap_compare(SNAPSHOT_APPS_DIR / "dock_scroll.py", terminal_size=(80, 25)) + + +def test_scroll_visible(snap_compare): + # https://github.com/Textualize/textual/issues/2181 + assert snap_compare(SNAPSHOT_APPS_DIR / "scroll_visible.py", press=["t"])