fixed ListView (src/textual/widgets/_list_view.py): clear stuck hover state during scrollbar drag#6380
Conversation
|
Thanks for your interest in contributing! This doesn't seem like the correct fix? When dragging a scrollbar, I wouldn't expect any mouse interactions like the hover effect in any widget, not just this issue with the |
|
Probably a misunderstanding on my part, I thought the hover (while dragging the scrollbar) effect was intentional since it looked nice and that the bug lied in the residual highlighting not getting cleaned up (as the issue's title suggested). |
|
What if the scrollbar being dragged is the screen or an outer container? If the mouse wanders into a I don't think this is the correct fix but I'm not a maintainer so this isn't really my call. |
|
Thanks for the feedback, I've updated the PR to include a more generic fix that simply disables hover interactions when dragging the scrollbar. This also covers the edge case you mentioned. |
Fixes #6259
Cause
When dragging the scrollbar, it'd call capture_mouse() which prevented Leave events from firing on ListItem widgets. This causes
items to remain in the -hovered state even after the mouse moves away.
Fix
Override _on_scroll_to in ListView to clear the -hovered class from
any items the mouse is no longer over whenever a scrollbar drag causes a scroll.
Reproduction
Run the MRE from the issue and drag the scrollbar sideways into the list.
Before this fix, items would remain highlighted after the mouse moved away.
After this fix, highlighted items return to their normal state when not hovered.