Skip to content

fix(android): sync IME selection so typing follows the tapped caret#2746

Merged
Alspb merged 1 commit into
singerdmx:masterfrom
Alspb:fix/android-caret-position-after-tap
Jun 29, 2026
Merged

fix(android): sync IME selection so typing follows the tapped caret#2746
Alspb merged 1 commit into
singerdmx:masterfrom
Alspb:fix/android-caret-position-after-tap

Conversation

@Alspb

@Alspb Alspb commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes an Android-only bug where typing inserted text at the previous caret
position after the caret was moved with a tap/mouse.

Issue

Open the editor → tap a different spot (caret visibly moves there) → type → text lands at the original position, not the
tapped one. Android only.

Reproduces with both the soft keyboard and a hardware keyboard, and only when the caret is moved by tap/mouse — moving it with the keyboard (arrow keys) works.

Root cause

The tapped selection is applied framework-side (controller.updateSelection) but never pushed to the platform IME. _didChangeTextEditingValue calls updateRemoteValueIfNeeded() only when ignoreFocus || _keyboardVisible. On
Android _keyboardVisible is false while the soft keyboard is hidden (always the case with a hardware keyboard), so after a tap the IME keeps its stale cursor and inserts there.

The issue surfaced after the Flutter 3.44 migration, whose Android text-input behavior no longer compensates for the missing setEditingState after a programmatic/tap selection change.

Fix

Call updateRemoteValueIfNeeded() in the keyboard-hidden branch as well.

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

Copilot AI review requested due to automatic review settings June 29, 2026 06:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Alspb
Alspb merged commit c273155 into singerdmx:master Jun 29, 2026
7 checks passed
smit-ghl pushed a commit to smit-ghl/flutter-quill that referenced this pull request Jul 7, 2026
* chore: fix pre-existing CI analyze failures (singerdmx#2728)

* feat: add onFocusReceived implementation for Flutter 3.44 compatibility (singerdmx#2726)

Implements the new TextInputClient.onFocusReceived method required by
Flutter SDK 3.44+. Returns false as the editor handles focus internally.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* chore(example): update deps, remove CocoaPods integration

* chore(release): prepare to publish 11.5.1

* chore(release): prepare to publish 11.5.1

* Complete the Flutter 3.44 / Dart 3.12 migration (singerdmx#2740)

* fix(example): repair Android build on Flutter 3.44 and finish the SDK bump

* chore(scripts): format only uncommitted Dart files in before_push

* fix: resolve Dart 3.12 analyzer warnings and lints

* Chore/dart 3.12 format (singerdmx#2744)

* style: apply Dart 3.12 format (tall style)

* ci: enforce repo-wide dart format + blame-ignore the reformat

* fix: normalize list point spacing when toggling RTL formatting (singerdmx#2745)

* fix(android): sync IME selection so typing follows the tapped caret (singerdmx#2746)

---------

Co-authored-by: Alspb <73047043+Alspb@users.noreply.github.com>
Co-authored-by: Jonathan Rezende <jonathan@jode.com.br>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Ellet <echo.ellet@gmail.com>
mkmkmk0706 pushed a commit to mkmkmk0706/flutter-quill that referenced this pull request Jul 10, 2026
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.

2 participants