Skip to content

fix: reveal caret when keyboard inset changes#2742

Open
Alspb wants to merge 1 commit into
singerdmx:masterfrom
Alspb:fix/caret-hidden-by-keyboard
Open

fix: reveal caret when keyboard inset changes#2742
Alspb wants to merge 1 commit into
singerdmx:masterfrom
Alspb:fix/caret-hidden-by-keyboard

Conversation

@Alspb

@Alspb Alspb commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Description

Unlike Flutter's EditableText, QuillRawEditorState never overrode
didChangeMetrics, so it didn't re-reveal the caret when the bottom view inset
(the on-screen keyboard) changed. The caret could stay hidden behind the keyboard
when it appeared or changed height mid-edit — e.g. on app resume, on an IME/emoji
switch or suggestion bar, or on rotation / split-screen / foldable resize.

Fix

QuillRawEditorState now overrides didChangeMetrics. The keyboard reports its
height frame-by-frame as it animates and can briefly overshoot before settling, so
revealing on every frame would pin the caret to that transient height. Instead the
inset changes are debounced (100 ms) and the caret is revealed once, after the
inset settles, against the final viewport.

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 12, 2026 07:38

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.

Pull request overview

This PR fixes an editor UX bug where the caret can remain obscured by the on-screen keyboard when the bottom view inset changes during an edit session. It adds a debounced response to viewport metric changes so the caret is re-revealed once the keyboard inset settles, aligning QuillRawEditorState behavior with Flutter’s EditableText.

Changes:

  • Override QuillRawEditorState.didChangeMetrics to re-reveal the caret after keyboard inset changes settle (debounced).
  • Track bottom inset changes and debounce caret reveal via a Timer.
  • Document the fix in the changelog.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/src/editor/raw_editor/raw_editor_state.dart Adds a debounced didChangeMetrics handler to re-reveal the caret after keyboard inset changes.
CHANGELOG.md Notes the caret reveal fix under Unreleased.
Comments suppressed due to low confidence (1)

lib/src/editor/raw_editor/raw_editor_state.dart:1137

  • A debounced caret-reveal timer can remain pending after the editor loses focus, because the timer is only cancelled in dispose() or by subsequent didChangeMetrics calls (which won’t run once the observer is removed). This can trigger an unexpected scroll animation after unfocus/keyboard dismissal.
    } else {
      WidgetsBinding.instance.removeObserver(this);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1141 to +1146
@override
void didChangeMetrics() {
if (!mounted) {
return;
}
final view = View.maybeOf(context);
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