Repository navigation
fix(touch): defer focus, blur, and selection changes to tap-up - #2558
Merged
Merged
Conversation
pascalandr
added a commit
to NeuralNomadsAI/rune
that referenced
this pull request
Nov 27, 2026
dev now defers a finger's focus, blur and selection changes to its lift as a tap for every touch host (anomalyco#2558), as decided on the Android design question. The fork's own version, behind host.text_menus, goes: touch.rs, pointer.rs and click.rs are dev's, and the fork's tests for a scroll that keeps a field's focus, a scroll from a field and a selection kept under a scroll pass on dev's implementation. Kept on top of dev's: the system's long-press delay (set_touch_long_press), whether the last finger panned (the selection toolbar's return), a long press's cancel_steps and on_text, and a field's tap told to the host (take_field_tap, from input_tap_up) so the keyboard comes back.
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.
Refs #2484 (answers question 3 in shared touch input across web, iOS, Android, and touchscreens).
Summary
Touching down on a screen previously ran
press_down's focus, blur, and selection logic immediately onTouchPhase::Started, beforeTOUCH_SLOP(8 pt) could tell a tap apart from a scroll pan, pinch, edge swipe, or long press. Scrolling a list while a text field was focused therefore queuedAction::Blur(dismissing the soft keyboard) or focused a scrolled-past field even when the touch turned into a pan.This change defers touch focus, blur, and text-field caret/selection changes to tap-up in the shared touch input path, matching Chrome, Android, and UIKit:
runtime/input/touch_machine.rs:Mode::Pendingrecordstap_focus(false when touch-down was swallowed by an active modal, autoscroll, another held button, or resize edge).step_single_endemitsTouchEffect::CommitTapbeforePointerUponly when lifting withinTOUCH_SLOPas a tap (andCommitWindowDragTapfor bare titlebar taps). EnteringMode::Dragon non-scrollable content emitsBeginTouchSelectionDragso dragging across non-scrollable selectable text continues to select text.runtime/input/pointer.rs&runtime/selection/click.rs: Extractapply_press_focusand split touch-down on text inputs (input_touch_down) from tap-up focus/caret placement (input_tap_up). Mouse presses (touch == false) are unchanged.runtime/input/touch.rs: ExecuteCommitTap(focus/blur/selection) immediately beforePointerUpsoon_presshandlers that calltx.focusstill win, while pans, pinches, edge swipes, long presses, and cancelled touches leave focus and text selection undisturbed.input/host_events.rs: In web document mode,web_touch_end_activatereturnsWebActivate::IfFieldFocusedwhen nothing was focused prior to the tap so tapping an unfocused text field activates the DOM input on the first tap after tap-up commits.changelog/unreleased/2026-11-27-touch-focus-on-tap-up.md.Testing
cargo test -p rune --lib -- runtime::input::touch input::host_events runtime::input::focus_key runtime::input::field_menu runtime::tests::press_pointer: 83 passed, 0 failed (including 3 new tests covering scroll-keeps-focus, tap-up focus/blur/double-tap, selection preservation on pan, and web document-mode first-tap activation).cargo test -p rune --test integration -- link_drag: 6 passed, 0 failed.cargo check -p rune --target wasm32-unknown-unknown: clean.