From 84db318e08ddc1becb8db53d5f17d99b544bea2d Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 29 Sep 2025 17:31:54 +0100 Subject: [PATCH 1/3] changelog --- CHANGELOG.md | 1 + src/textual/css/_style_properties.py | 6 ++++++ tests/snapshot_tests/test_snapshots.py | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d72a52b..5e79bbba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed visual glitches and crash when changing `DataTable.header_height` https://github.com/Textualize/textual/pull/6128 - Fixed TextArea.placeholder not handling multi-lines https://github.com/Textualize/textual/pull/6138 - Fixed issue with RichLog when App.theme is set early https://github.com/Textualize/textual/pull/6141 +- Fixed children of collapsible not being focusable after collapsible is expanded ## [6.1.0] - 2025-08-01 diff --git a/src/textual/css/_style_properties.py b/src/textual/css/_style_properties.py index edc591966..2b3ebfe77 100644 --- a/src/textual/css/_style_properties.py +++ b/src/textual/css/_style_properties.py @@ -841,6 +841,12 @@ class StringEnumProperty(Generic[EnumType]): children=self._refresh_children, parent=self._refresh_parent, ) + + if self._display: + node = obj.node + if node is not None and node.parent: + node._nodes.updated() + else: if value not in self._valid_values: raise StyleValueError( diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 034dfd799..ea8a7434f 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -4675,3 +4675,18 @@ def test_rich_log_early_write(snap_compare) -> None: log_widget.write("Hello, World!") assert snap_compare(TestApp()) + + +def test_collapsible_focus_children(snap_compare) -> None: + """Regression test for https://github.com/Textualize/textual/issues/6140 + + You should see an expanded collapsible containing a button. The button should be focused. + + """ + + class CollapseApp(App): + def compose(self) -> ComposeResult: + with Collapsible(title="Collapsible", collapsed=False): + yield Button("Hello") + + assert snap_compare(CollapseApp(), press=["enter", "enter", "tab"]) From a3927841a32e7978f07222ffcfb69c4adeef4f03 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 29 Sep 2025 17:32:56 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e79bbba6..fb0a39404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed visual glitches and crash when changing `DataTable.header_height` https://github.com/Textualize/textual/pull/6128 - Fixed TextArea.placeholder not handling multi-lines https://github.com/Textualize/textual/pull/6138 - Fixed issue with RichLog when App.theme is set early https://github.com/Textualize/textual/pull/6141 -- Fixed children of collapsible not being focusable after collapsible is expanded +- Fixed children of collapsible not being focusable after collapsible is expanded https://github.com/Textualize/textual/pull/6143 ## [6.1.0] - 2025-08-01 From aade7a679223b60545662ced229d580b43538b7a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 29 Sep 2025 18:01:41 +0100 Subject: [PATCH 3/3] snapshot --- .../test_collapsible_focus_children.svg | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 tests/snapshot_tests/__snapshots__/test_snapshots/test_collapsible_focus_children.svg diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_collapsible_focus_children.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_collapsible_focus_children.svg new file mode 100644 index 000000000..dc36c01d2 --- /dev/null +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_collapsible_focus_children.svg @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CollapseApp + + + + + + + + + + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ +▼ Collapsible + +▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + Hello  +▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + + + + + + + + + + + + + + + + + + + +