Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scrollable containers focusable. #2317

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/textual/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand All @@ -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 = """
Expand Down
8 changes: 5 additions & 3 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down