Skip to content

Commit 3080464

Browse files
authored
Merge pull request #6214 from Textualize/fix-hover-flicker
Fix hover flicker
2 parents aed5879 + 3e363d4 commit 3080464

File tree

7 files changed

+36
-17
lines changed

7 files changed

+36
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- Fixed `TextArea` cursor display on wrapped lines https://github.com/Textualize/textual/pull/6196
1313
- Fixed `remove_children` not refreshing layout https://github.com/Textualize/textual/pull/6206
14+
- Fixed flicker with :hover pseudo class https://github.com/Textualize/textual/pull/6214
1415

1516
### Added
1617

1718
- Added `grid_size` property to `GridLayout` https://github.com/Textualize/textual/pull/6210
19+
- Exposed `NoSelection` and `BLANK` via `textual.widgets.select` https://github.com/Textualize/textual/pull/6214
20+
21+
### Changed
22+
23+
- Change highlight style of Select to only highlight the border, not the label https://github.com/Textualize/textual/pull/6214
1824

1925
## [6.5.0] - 2025-10-31
2026

src/textual/app.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,11 +3037,17 @@ def _set_mouse_over(
30373037
widget.post_message(events.Enter(widget))
30383038
finally:
30393039
self.mouse_over = widget
3040-
if self.hover_over is not None:
3041-
self.hover_over.mouse_hover = False
3040+
3041+
current_hover_over = self.hover_over
3042+
if current_hover_over is not None:
3043+
current_hover_over.mouse_hover = False
3044+
30423045
if hover_widget is not None:
30433046
hover_widget.mouse_hover = True
3044-
3047+
if hover_widget._has_hover_style:
3048+
hover_widget._update_styles()
3049+
if current_hover_over is not None and current_hover_over._has_hover_style:
3050+
current_hover_over._update_styles()
30453051
self.hover_over = hover_widget
30463052

30473053
def _update_mouse_over(self, screen: Screen) -> None:

src/textual/widget.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,11 +3963,6 @@ def post_render(
39633963

39643964
return renderable
39653965

3966-
def watch_mouse_hover(self, _mouse_over: bool) -> None:
3967-
"""Update from CSS if mouse over state changes."""
3968-
if self._has_hover_style:
3969-
self._update_styles()
3970-
39713966
def watch_has_focus(self, _has_focus: bool) -> None:
39723967
"""Update from CSS if has focus state changes."""
39733968
self._update_styles()

src/textual/widgets/_toggle_button.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ class ToggleButton(Static, can_focus=True):
6464
&.-textual-compact {
6565
border: none !important;
6666
padding: 0;
67+
&:focus {
68+
border: tall $border;
69+
background-tint: $foreground 5%;
70+
& > .toggle--label {
71+
color: $block-cursor-foreground;
72+
background: $block-cursor-background;
73+
text-style: $block-cursor-text-style;
74+
}
75+
}
6776
}
6877
6978
& > .toggle--button {
@@ -80,9 +89,7 @@ class ToggleButton(Static, can_focus=True):
8089
border: tall $border;
8190
background-tint: $foreground 5%;
8291
& > .toggle--label {
83-
color: $block-cursor-foreground;
84-
background: $block-cursor-background;
85-
text-style: $block-cursor-text-style;
92+
color: $block-cursor-foreground;
8693
}
8794
}
8895
&:blur:hover {

src/textual/widgets/select.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
from textual.widgets._select import EmptySelectError, InvalidSelectValueError
1+
from textual.widgets._select import (
2+
BLANK,
3+
EmptySelectError,
4+
InvalidSelectValueError,
5+
NoSelection,
6+
)
27

3-
__all__ = ["EmptySelectError", "InvalidSelectValueError"]
8+
__all__ = ["EmptySelectError", "InvalidSelectValueError", "NoSelection", "BLANK"]

tests/snapshot_tests/__snapshots__/test_snapshots/test_checkbox_example.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/snapshot_tests/__snapshots__/test_snapshots/test_toggle_style_order.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)