-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrollbars may trap the mouse if hidden while the user is scrolling #4274
Comments
At a guess, I suspect it is the mouse capture system not "releasing" the mouse, if the scrollbar is made invisible. Feels like an easy fix. |
I'm sure the maintainers are way ahead of me on this, but posting my findings anyway in case it helps... The textual/src/textual/scrollbar.py Lines 291 to 294 in c7370f3
But more importantly this issue isn't only with scrollbars, but any widget which captures the mouse. For example, if you start a mouse selection with the |
Just to confirm things: I think @TomJGooding has perfectly summed up the issue here. The situation presented with the MRE above won't result in a |
Digging deeper, what is interesting is the other contents do get a diff --git a/src/textual/screen.py b/src/textual/screen.py
index f9674a47..1cee5b11 100644
--- a/src/textual/screen.py
+++ b/src/textual/screen.py
@@ -793,6 +793,8 @@ class Screen(Generic[ScreenResultType], Widget):
for widget in hidden:
widget.post_message(Hide())
+ if widget.vertical_scrollbar is not None:
+ widget.vertical_scrollbar.post_message(Hide())
# We want to send a resize event to widgets that were just added or change since last layout
send_resize = shown | resized while likely not the actual fix to go with, I think it does suggest that it isn't down to a specific event not being posted, it's just that it isn't being posted as widely as it should. |
The idea here being that while scrollbars are attached to widgets, they exist outwith of the DOM, and so don't seem to take part in the usual flow of show/hide messaging. This change checks, when posting a show/hide message, if the widget receiving the message has scrollbars and if it does the message is also sent to them too. Fixes Textualize#4274.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Now that the fix is available in |
Current behaviour
If a scrollable widget is programmatically hidden while the user is scrolling by dragging the scrollbar handle, all mouse events are seemingly blocked (they are actually trapped by the invisible scrollbar).
This MRE reproduces the issue by programmatically collapsing a
Collapsible
that contains a scrollableRichLog
:Expectations
The scrollbar handle should be "released" as soon as the scrollbar is hidden so that mouse events resume their normal course.
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: