From 4414ecc4601da556df9339b02a544bef8398f3f6 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Wed, 17 Jul 2024 13:02:35 +0100 Subject: [PATCH] Ensure hover effect doesnt linger when mouse leaves Tree (#4766) * Ensure hover effect doesnt linger when mouse leaves Tree * Update CHANGELOG --- CHANGELOG.md | 1 + src/textual/widgets/_tree.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5979857614..fc0ce04005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `TreeNodeSelected` messages are now posted before `TreeNodeExpanded` messages when an expandable node is selected https://github.com/Textualize/textual/pull/4753 - `Markdown.LinkClicked.href` is now automatically unquoted https://github.com/Textualize/textual/pull/4749 +- The mouse cursor hover effect of `Tree` and `DirectoryTree` will no longer linger after the mouse leaves the widget https://github.com/Textualize/textual/pull/4766 ## [0.72.0] - 2024-07-09 diff --git a/src/textual/widgets/_tree.py b/src/textual/widgets/_tree.py index 9ee5227444..ed44340d76 100644 --- a/src/textual/widgets/_tree.py +++ b/src/textual/widgets/_tree.py @@ -839,6 +839,10 @@ def _on_mouse_move(self, event: events.MouseMove) -> None: else: self.hover_line = -1 + def _on_leave(self, _: events.Leave) -> None: + # Ensure the hover effect doesn't linger after the mouse leaves. + self.hover_line = -1 + def _new_id(self) -> NodeID: """Create a new node ID.