Repository navigation
scrollbar: Only drag or jump the track on the primary button - #4038
Merged
madcodelife merged 1 commit intoNov 18, 2026
Merged
Conversation
A right or middle press on a scrollbar started a thumb drag or jumped the track, and a non-primary release ended an ongoing primary drag. Check event.button in the mouse-down and mouse-up handlers. Closes #4036
Member
|
✅ Correct, minimal fix; scrollbar press and release now only react to the primary button. Reviewed head
Ran
|
madcodelife
approved these changes
Nov 18, 2026
Member
|
Thank you! |
Contributor
Author
|
Thanks for merging! |
linruohan
pushed a commit
to linruohan/gpui-kit
that referenced
this pull request
Nov 20, 2026
…dge#4038) Closes longbridge#4036 ## Description `Scrollbar::paint` didn't check `event.button`, so a right or middle press on the thumb started a drag and a press on the track jumped it, and the press was stopped there. A non-left release also ended an ongoing left drag. Both the mouse-down and mouse-up handlers now only act on `MouseButton::Left`, as the issue suggested. The drag move handler already only acts while the left button is held (`event.dragging()`), and hover tracking stays button-agnostic. Since the scrollbar no longer stops a right or middle press, it reaches the content underneath, so an app's right-click menu can open over the scrollbar. The component and shell scroll wrappers use the base `Scrollbar`, so they pick this up too. `slider`, `resize_handle` and `carousel/scroll_mask` already check for the left button. ## How to Test - New test `only_the_primary_button_drags_or_jumps` in `crates/base/src/scrollbar.rs` (uses the existing harness): right and middle down/up on the thumb and on the track don't start a drag or move the offset, and a right release during a left drag doesn't end it. It fails with either check removed. - `cargo test -p gpui-base` (1769 lib tests plus the other targets), `cargo clippy -p gpui-base --all-targets -- -D warnings`, `rustfmt --check` on the file, `typos`. - Tested on macOS. I didn't click through the story app by hand; the test drives real mouse events through gpui's dispatch with the real `Scrollbar`. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [ ] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) The fix and test in this PR were written with AI assistance (Claude) and reviewed against the project's style.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4036
Description
Scrollbar::paintdidn't checkevent.button, so a right or middle press on the thumb started a drag and a press on the track jumped it, and the press was stopped there. A non-left release also ended an ongoing left drag.Both the mouse-down and mouse-up handlers now only act on
MouseButton::Left, as the issue suggested. The drag move handler already only acts while the left button is held (event.dragging()), and hover tracking stays button-agnostic. Since the scrollbar no longer stops a right or middle press, it reaches the content underneath, so an app's right-click menu can open over the scrollbar.The component and shell scroll wrappers use the base
Scrollbar, so they pick this up too.slider,resize_handleandcarousel/scroll_maskalready check for the left button.How to Test
only_the_primary_button_drags_or_jumpsincrates/base/src/scrollbar.rs(uses the existing harness): right and middle down/up on the thumb and on the track don't start a drag or move the offset, and a right release during a left drag doesn't end it. It fails with either check removed.cargo test -p gpui-base(1769 lib tests plus the other targets),cargo clippy -p gpui-base --all-targets -- -D warnings,rustfmt --checkon the file,typos.Scrollbar.Checklist
cargo runfor story tests related to the changes.The fix and test in this PR were written with AI assistance (Claude) and reviewed against the project's style.