diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b46f0b9e..ec2de8a072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Breaking change: Timer.start is now private, and returns No - A clicked tab will now be scrolled to the center of its tab container https://github.com/Textualize/textual/pull/2276 - `ButtonVariant` is now exported from `textual.widgets.button` https://github.com/Textualize/textual/issues/2264 +- `HorizontalScroll` and `VerticalScroll` are now focusable by default https://github.com/Textualize/textual/pull/2317 ### Added diff --git a/src/textual/containers.py b/src/textual/containers.py index 99605ace70..9d6c35b7f6 100644 --- a/src/textual/containers.py +++ b/src/textual/containers.py @@ -31,7 +31,7 @@ class Vertical(Widget): """ -class VerticalScroll(Widget): +class VerticalScroll(Widget, can_focus=True): """A container which arranges children vertically, with an automatic vertical scrollbar.""" DEFAULT_CSS = """ @@ -55,7 +55,7 @@ class Horizontal(Widget): """ -class HorizontalScroll(Widget): +class HorizontalScroll(Widget, can_focus=True): """A container which arranges children horizontally, with an automatic horizontal scrollbar.""" DEFAULT_CSS = """ diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index e8bde50c72..2ab2ba63c3 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -87,7 +87,7 @@ def test_input_and_focus(snap_compare): def test_buttons_render(snap_compare): # Testing button rendering. We press tab to focus the first button too. - assert snap_compare(WIDGET_EXAMPLES_DIR / "button.py", press=["tab"]) + assert snap_compare(WIDGET_EXAMPLES_DIR / "button.py", press=["tab", "tab"]) def test_placeholder_render(snap_compare): @@ -269,7 +269,7 @@ def test_programmatic_scrollbar_gutter_change(snap_compare): def test_borders_preview(snap_compare): - assert snap_compare(CLI_PREVIEWS_DIR / "borders.py", press=["tab", "enter"]) + assert snap_compare(CLI_PREVIEWS_DIR / "borders.py", press=["tab", "tab", "enter"]) def test_colors_preview(snap_compare): @@ -325,7 +325,9 @@ def test_disabled_widgets(snap_compare): def test_focus_component_class(snap_compare): - assert snap_compare(SNAPSHOT_APPS_DIR / "focus_component_class.py", press=["tab"]) + assert snap_compare( + SNAPSHOT_APPS_DIR / "focus_component_class.py", press=["tab", "tab"] + ) def test_line_api_scrollbars(snap_compare):