Skip to content

Commit

Permalink
Fix ListView styling (#5304)
Browse files Browse the repository at this point in the history
* Quick fixes to list view styles

* Updating snapshots

* Update changelog
  • Loading branch information
darrenburns authored Nov 28, 2024
1 parent ca9b4a8 commit 79df474
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 150 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed infinite loop in `Widget.anchor` https://github.com/Textualize/textual/pull/5290
- Restores the ability to supply console markup to command list https://github.com/Textualize/textual/pull/5294
- Fixed delayed App Resize event https://github.com/Textualize/textual/pull/5296
- Fixed ListView focus styling rule being too broad https://github.com/Textualize/textual/pull/5304
- Fixed issue with auto-generated tab IDs https://github.com/Textualize/textual/pull/5298

## [0.87.1] - 2024-11-24
Expand Down
7 changes: 1 addition & 6 deletions examples/theme_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,7 @@ class ChangingThemeApp(App[None]):
}
ListView {
height: auto;
& > ListItem {
width: 1fr;
& > Label {
width: 1fr;
}
}
}
Tree {
height: 5;
Expand Down
66 changes: 48 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions src/textual/widgets/_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
DEFAULT_CSS = """
ListView {
background: $surface;
&:focus-within {
background-tint: $foreground 5%;
}
& > ListItem {
color: $foreground;
height: auto;
Expand All @@ -51,12 +47,15 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
}
}
&:focus > ListItem.-highlight > Widget {
width: 1fr;
color: $block-cursor-foreground;
background: $block-cursor-background;
text-style: $block-cursor-text-style;
&:focus {
background-tint: $foreground 5%;
& > ListItem.-highlight {
color: $block-cursor-foreground;
background: $block-cursor-background;
text-style: $block-cursor-text-style;
}
}
}
"""

Expand Down
Loading

0 comments on commit 79df474

Please sign in to comment.