fix: reveal caret when keyboard inset changes#2742
Open
Alspb wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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.didChangeMetricsto 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); |
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
Unlike Flutter's
EditableText,QuillRawEditorStatenever overrodedidChangeMetrics, 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
QuillRawEditorStatenow overridesdidChangeMetrics. The keyboard reports itsheight 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