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

Blur #3645

Merged
merged 5 commits into from
Nov 7, 2023
Merged

Blur #3645

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 @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Duplicate CSS errors when parsing CSS from a screen https://github.com/Textualize/textual/issues/3581
- Added missing `blur` pseudo class https://github.com/Textualize/textual/issues/3439

### Changed

Expand Down
1 change: 1 addition & 0 deletions docs/guide/CSS.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Here are some other pseudo classes:
- `:disabled` Matches widgets which are in a disabled state.
- `:enabled` Matches widgets which are in an enabled state.
- `:focus` Matches widgets which have input focus.
- `:blur` Matches widgets which *do not* have input focus.
- `:focus-within` Matches widgets with a focused child widget.
- `:dark` Matches widgets in dark mode (where `App.dark == True`).
- `:light` Matches widgets in dark mode (where `App.dark == False`).
Expand Down
2 changes: 2 additions & 0 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,8 @@ def get_pseudo_classes(self) -> Iterable[str]:
yield "hover"
if self.has_focus:
yield "focus"
else:
yield "blur"
if self.can_focus:
yield "can-focus"
try:
Expand Down
15 changes: 13 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,25 @@ async def test_hover_update_styles():
app = MyApp()
async with app.run_test() as pilot:
button = app.query_one(Button)
assert button.pseudo_classes == {"enabled", "can-focus", "dark"}
assert button.pseudo_classes == {
"blur",
"can-focus",
"dark",
"enabled",
}

# Take note of the initial background colour
initial_background = button.styles.background
await pilot.hover(Button)

# We've hovered, so ensure the pseudoclass is present and background changed
assert button.pseudo_classes == {"enabled", "hover", "can-focus", "dark"}
assert button.pseudo_classes == {
"blur",
"can-focus",
"dark",
"enabled",
"hover",
}
assert button.styles.background != initial_background


Expand Down
Loading