Skip to content

Commit 38ca1dd

Browse files
authored
Merge pull request #6143 from Textualize/fix-collapsible-focus
Fix focus after collapsible is expanded
2 parents b00c159 + aade7a6 commit 38ca1dd

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3333
- Fixed visual glitches and crash when changing `DataTable.header_height` https://github.com/Textualize/textual/pull/6128
3434
- Fixed TextArea.placeholder not handling multi-lines https://github.com/Textualize/textual/pull/6138
3535
- Fixed issue with RichLog when App.theme is set early https://github.com/Textualize/textual/pull/6141
36+
- Fixed children of collapsible not being focusable after collapsible is expanded https://github.com/Textualize/textual/pull/6143
3637

3738
## [6.1.0] - 2025-08-01
3839

src/textual/css/_style_properties.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ def __set__(self, obj: StylesBase, value: EnumType | None = None):
841841
children=self._refresh_children,
842842
parent=self._refresh_parent,
843843
)
844+
845+
if self._display:
846+
node = obj.node
847+
if node is not None and node.parent:
848+
node._nodes.updated()
849+
844850
else:
845851
if value not in self._valid_values:
846852
raise StyleValueError(
Lines changed: 154 additions & 0 deletions
Loading

tests/snapshot_tests/test_snapshots.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,3 +4675,18 @@ def on_ready(self) -> None:
46754675
log_widget.write("Hello, World!")
46764676

46774677
assert snap_compare(TestApp())
4678+
4679+
4680+
def test_collapsible_focus_children(snap_compare) -> None:
4681+
"""Regression test for https://github.com/Textualize/textual/issues/6140
4682+
4683+
You should see an expanded collapsible containing a button. The button should be focused.
4684+
4685+
"""
4686+
4687+
class CollapseApp(App):
4688+
def compose(self) -> ComposeResult:
4689+
with Collapsible(title="Collapsible", collapsed=False):
4690+
yield Button("Hello")
4691+
4692+
assert snap_compare(CollapseApp(), press=["enter", "enter", "tab"])

0 commit comments

Comments
 (0)