Skip to content

fix(text_field): keep the selection a shift-click extends - #595

Draft
botty87 wants to merge 1 commit into
macosui:devfrom
botty87:fix/shift-click-selection
Draft

botty87 wants to merge 1 commit into
macosui:devfrom
botty87:fix/shift-click-selection

Conversation

@botty87

@botty87 botty87 commented Nov 5, 2026

Copy link
Copy Markdown

On macOS (and Windows/Linux), placing the caret in a MacosTextField and then shift-clicking elsewhere shows the extended selection for an instant, and it collapses as soon as the mouse button is released.

Why: Flutter's TextSelectionGestureDetectorBuilder sets the selection on tap down on desktop platforms, which is where a shift-click extends it; its onSingleTapUp deliberately does nothing there ("On desktop platforms the selection is set on tap down"). _TextFieldSelectionGestureDetectorBuilder.onSingleTapUp called renderEditable.selectPosition unconditionally, collapsing the selection on release. Drag selection was not affected because it ends in onDragSelectionEnd.

Fix: skip selectPosition on tap up on desktop platforms; mobile behaviour is unchanged.

Tests: a shift-click test over TargetPlatformVariant.desktop() (fails before the fix) and a plain-click test over all platforms.

Pre-launch Checklist

  • I have incremented the package version as appropriate and updated CHANGELOG.md with my changes (added under the unreleased 2.2.3)
  • I have added/updated relevant documentation
  • I have run "optimize/organize imports" on all changed files
  • I have addressed all analyzer warnings as best I could

🤖 Generated with Claude Code

On desktop platforms TextSelectionGestureDetectorBuilder sets the
selection on tap down, where a shift-click extends it. MacosTextField
placed the caret again on tap up, so the extended selection flashed and
collapsed as soon as the mouse button was released. Like Flutter's own
builder, it now leaves the selection to tap down on macOS, Windows and
Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant