slider: Let a touch drag on the track move the thumb - #3313
Merged
Merged
Conversation
On touch platforms GPUI delivers a finger drag as TouchDragEvent (when a handler claims it with prevent_default on Started) or as scrolling; on_drag drag-and-drop is mouse-only. The slider therefore could not be dragged by finger on Android/iOS, and the drag scrolled the page instead. SliderTrack now claims touch drags that start on the track and feeds them through the same update_value_by_position / handle_release path as the mouse, picking the nearer thumb for range sliders. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The Android text system has no `monospace` alias, so FpsMonitor's default font resolved to nothing and GPUI panicked when the HUD first rendered. Use Droid Sans Mono, which every Android image ships. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 29, 2026
…n gesture A covering layer (dialog, sheet, popover) now keeps drags that start over the slider, and a drag whose end never reached the slider (disabled or not painted mid-drag) no longer lets later gestures move the thumb. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
huacnlee
enabled auto-merge (squash)
September 29, 2026 14:25
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.
Description
Thank you for GPUI Kit, and for making it usable on mobile at all. While testing every Kit 0.7.0 component on Android (through gpui-mobile), I found two small problems with clear fixes, so I'm proposing them here. Each is a separate commit, and I'm happy to split them into separate PRs, change the approach, or drop either one if it doesn't fit how you want to handle touch. The remaining findings are collected in #3310.
1. Slider: a touch drag on the track moves the thumb
On touch platforms (gpui-mobile on Android/iOS), a finger on the slider track could not move the thumb: GPUI delivers a finger drag as
TouchDragEvent(when a handler claims it withwindow.prevent_default()onStarted) or as scrolling, whileon_dragdrag-and-drop only reacts to the mouse. Dragging a slider scrolled the page instead.SliderTracknow adds an absolutely positionedcanvaslayer (only when not disabled) that claims touch drags starting on the track and feeds them through the existingupdate_value_by_position/handle_releasepath, soSliderEvent::ChangeandSliderEvent::Releasefire as for the mouse. For range sliders the thumb nearer to the touch start moves. Drags already claimed by another handler are left alone, and mouse behaviour is unchanged.2. fps: use Droid Sans Mono on Android
On Android, the first render of
FpsMonitorpanics:DEFAULT_FONTfalls through to"monospace", which Android's cosmic-text backend does not resolve as an alias. None of GPUI's desktop fallbacks exist there either, so font resolution fails. iOS already has its own branch for the same reason.This adds an Android branch that uses
Droid Sans Mono, a family every Android system image ships (/system/fonts/DroidSansMono.ttf).Screenshot
Slider: behavioural change, no visual difference. fps: before, the app aborts with
failed to resolve font 'monospace' or any of the fallbackswhen the HUD first paints; after, the HUD renders.How to Test
slider_touch_drag_moves_the_actual_thumbincrates/kit/tests/disclosure.rsdispatchesTouchDragEventStarted/Moved/Ended and checks the thumb follows in both directions. It fails without the change (assertion failed: after.center().x > before.center().x) and passes with it.disabled_slider_ignores_pointer_changesnow also checks that a touch drag leaves a disabled slider alone.cargo test -p gpui-kit --features test-support,component --test disclosure: 6 passed.cargo check -p gpui-fpsandcargo fmt --checkpass on Linux (non-Android targets compile the same code as before).Checklist
cargo runfor story tests related to the changes. (Not run; the slider is covered by the test above, the fps change is an Android-onlycfg.)Playground used for the on-device testing: Bombatomica64/Gpui-android (prebuilt APK), in case you want to try these changes on Android.
Thanks for taking the time to review this.
🤖 Generated with Claude Code