diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dae36477b..c45cbb4163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed `TextArea` cursor display on wrapped lines https://github.com/Textualize/textual/pull/6196 - Fixed `remove_children` not refreshing layout https://github.com/Textualize/textual/pull/6206 +- Fixed flicker with :hover pseudo class https://github.com/Textualize/textual/pull/6214 ### Added - Added `grid_size` property to `GridLayout` https://github.com/Textualize/textual/pull/6210 +- Exposed `NoSelection` and `BLANK` via `textual.widgets.select` https://github.com/Textualize/textual/pull/6214 + +### Changed + +- Change highlight style of Select to only highlight the border, not the label https://github.com/Textualize/textual/pull/6214 ## [6.5.0] - 2025-10-31 diff --git a/src/textual/app.py b/src/textual/app.py index 32254ea82e..534f38e6a9 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -3037,11 +3037,17 @@ def _set_mouse_over( widget.post_message(events.Enter(widget)) finally: self.mouse_over = widget - if self.hover_over is not None: - self.hover_over.mouse_hover = False + + current_hover_over = self.hover_over + if current_hover_over is not None: + current_hover_over.mouse_hover = False + if hover_widget is not None: hover_widget.mouse_hover = True - + if hover_widget._has_hover_style: + hover_widget._update_styles() + if current_hover_over is not None and current_hover_over._has_hover_style: + current_hover_over._update_styles() self.hover_over = hover_widget def _update_mouse_over(self, screen: Screen) -> None: diff --git a/src/textual/widget.py b/src/textual/widget.py index 4d6115ff97..d02bb237fe 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -3963,11 +3963,6 @@ def post_render( return renderable - def watch_mouse_hover(self, _mouse_over: bool) -> None: - """Update from CSS if mouse over state changes.""" - if self._has_hover_style: - self._update_styles() - def watch_has_focus(self, _has_focus: bool) -> None: """Update from CSS if has focus state changes.""" self._update_styles() diff --git a/src/textual/widgets/_toggle_button.py b/src/textual/widgets/_toggle_button.py index 720e7c77d7..66f28da539 100644 --- a/src/textual/widgets/_toggle_button.py +++ b/src/textual/widgets/_toggle_button.py @@ -64,6 +64,15 @@ class ToggleButton(Static, can_focus=True): &.-textual-compact { border: none !important; padding: 0; + &:focus { + border: tall $border; + background-tint: $foreground 5%; + & > .toggle--label { + color: $block-cursor-foreground; + background: $block-cursor-background; + text-style: $block-cursor-text-style; + } + } } & > .toggle--button { @@ -80,9 +89,7 @@ class ToggleButton(Static, can_focus=True): border: tall $border; background-tint: $foreground 5%; & > .toggle--label { - color: $block-cursor-foreground; - background: $block-cursor-background; - text-style: $block-cursor-text-style; + color: $block-cursor-foreground; } } &:blur:hover { diff --git a/src/textual/widgets/select.py b/src/textual/widgets/select.py index 9c52c35b89..91b5b3657c 100644 --- a/src/textual/widgets/select.py +++ b/src/textual/widgets/select.py @@ -1,3 +1,8 @@ -from textual.widgets._select import EmptySelectError, InvalidSelectValueError +from textual.widgets._select import ( + BLANK, + EmptySelectError, + InvalidSelectValueError, + NoSelection, +) -__all__ = ["EmptySelectError", "InvalidSelectValueError"] +__all__ = ["EmptySelectError", "InvalidSelectValueError", "NoSelection", "BLANK"] diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_checkbox_example.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_checkbox_example.svg index dc566ddf72..5644cceb3d 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots/test_checkbox_example.svg +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_checkbox_example.svg @@ -44,7 +44,7 @@ .terminal-r10 { fill: #8ad4a1 } .terminal-r11 { fill: #0178d4 } .terminal-r12 { fill: #000000 } -.terminal-r13 { fill: #ddedf9;font-weight: bold } +.terminal-r13 { fill: #e2e2e2 } @@ -130,7 +130,7 @@ - + diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_toggle_style_order.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_toggle_style_order.svg index 7622ee8373..5872e76dc8 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots/test_toggle_style_order.svg +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_toggle_style_order.svg @@ -39,7 +39,7 @@ .terminal-r5 { fill: #000f18 } .terminal-r6 { fill: #e0e0e0 } .terminal-r7 { fill: #ff0000;font-weight: bold } -.terminal-r8 { fill: #80bbe9;font-weight: bold } +.terminal-r8 { fill: #939393 } .terminal-r9 { fill: #880909;font-weight: bold } .terminal-r10 { fill: #888888 } @@ -127,7 +127,7 @@ - + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ XThis is just some text.