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

Fix ListView styling #5304

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -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

## [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
Loading