Skip to content

fixed ListView (src/textual/widgets/_list_view.py): clear stuck hover state during scrollbar drag#6380

Open
Hoteira wants to merge 2 commits intoTextualize:mainfrom
Hoteira:fix-listview-hover-stuck-on-scrollbar-drag
Open

fixed ListView (src/textual/widgets/_list_view.py): clear stuck hover state during scrollbar drag#6380
Hoteira wants to merge 2 commits intoTextualize:mainfrom
Hoteira:fix-listview-hover-stuck-on-scrollbar-drag

Conversation

@Hoteira
Copy link

@Hoteira Hoteira commented Feb 18, 2026

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.

@TomJGooding
Copy link
Collaborator

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 ListView?

@Hoteira
Copy link
Author

Hoteira commented Feb 19, 2026

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).
If you confirm the effect should not happen at all I have no problem updating my fix.

@TomJGooding
Copy link
Collaborator

What if the scrollbar being dragged is the screen or an outer container? If the mouse wanders into a ListView while scrolling, you see the same issues with the hover effect.

I don't think this is the correct fix but I'm not a maintainer so this isn't really my call.

@Hoteira
Copy link
Author

Hoteira commented Feb 20, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scrolling ListView with mouse leaves items boosted from hovering

2 participants