Skip to content

Commit 79df474

Browse files
authored
Fix ListView styling (#5304)
* Quick fixes to list view styles * Updating snapshots * Update changelog
1 parent ca9b4a8 commit 79df474

File tree

6 files changed

+175
-150
lines changed

6 files changed

+175
-150
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Fixed infinite loop in `Widget.anchor` https://github.com/Textualize/textual/pull/5290
1313
- Restores the ability to supply console markup to command list https://github.com/Textualize/textual/pull/5294
1414
- Fixed delayed App Resize event https://github.com/Textualize/textual/pull/5296
15+
- Fixed ListView focus styling rule being too broad https://github.com/Textualize/textual/pull/5304
1516
- Fixed issue with auto-generated tab IDs https://github.com/Textualize/textual/pull/5298
1617

1718
## [0.87.1] - 2024-11-24

examples/theme_sandbox.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,7 @@ class ChangingThemeApp(App[None]):
190190
}
191191
ListView {
192192
height: auto;
193-
& > ListItem {
194-
width: 1fr;
195-
& > Label {
196-
width: 1fr;
197-
}
198-
}
193+
199194
}
200195
Tree {
201196
height: 5;

poetry.lock

Lines changed: 48 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/textual/widgets/_list_view.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
3030
DEFAULT_CSS = """
3131
ListView {
3232
background: $surface;
33-
&:focus-within {
34-
background-tint: $foreground 5%;
35-
}
36-
3733
& > ListItem {
3834
color: $foreground;
3935
height: auto;
@@ -51,12 +47,15 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
5147
}
5248
}
5349
54-
&:focus > ListItem.-highlight > Widget {
55-
width: 1fr;
56-
color: $block-cursor-foreground;
57-
background: $block-cursor-background;
58-
text-style: $block-cursor-text-style;
50+
&:focus {
51+
background-tint: $foreground 5%;
52+
& > ListItem.-highlight {
53+
color: $block-cursor-foreground;
54+
background: $block-cursor-background;
55+
text-style: $block-cursor-text-style;
56+
}
5957
}
58+
6059
}
6160
"""
6261

0 commit comments

Comments
 (0)