Dismiss caret on Android when the virtual keyboard is closed without blur#4444
Open
Copilot wants to merge 5 commits into
Open
Dismiss caret on Android when the virtual keyboard is closed without blur#4444Copilot wants to merge 5 commits into
Copilot wants to merge 5 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix caret not dismissed with down arrow keyboard action
Dismiss caret on Android when the virtual keyboard is closed without blur
Jun 24, 2026
…3958) The Capacitor Android app does not resize the WebView when the keyboard opens/closes (windowSoftInputMode=adjustNothing + IME inset stripping in MainActivity, mirroring iOS Keyboard resize:'none'), so the visualViewport resize event never fires and the previous resize-based handler never ran on the device. Dismissing the keyboard via the Down Arrow nav-bar button also does not blur the editable, so no blur event dismisses the caret. Add an Android Capacitor virtual-keyboard handler that listens to the native keyboardDidHide event and clears the caret / exits edit mode. Extract the shared dismissCaretOnKeyboardClose helper, reused by the existing resize handler (which still covers Android mobile web/PWA where the viewport resizes). Add a unit test mocking @capacitor/keyboard to cover the new handler, since the native path cannot be exercised by Puppeteer.
BayuAri
reviewed
Jun 24, 2026
BayuAri
left a comment
Collaborator
There was a problem hiding this comment.
Confirm fixed.
Caret is auto dismissed along with keyboard when closed from down arrow on the nav bar.
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.
On Android, dismissing the virtual keyboard with the Down Arrow button hides the keyboard without blurring the editable, so no blur event fires and the caret keeps blinking on the thought.
Root cause
src/util/handleKeyboardVisibility.tsalready detects the keyboard closing from avisualViewportresize and exits edit mode (clears the selection, setsisKeyboardOpen: false), but it was never attached to any listener — effectively dead code. The only resize listener wired (updateSize) does not touch the caret, and Android has no active virtual-keyboard handler (iOSSafariHandlerearly-returns when not Safari).Changes
src/util/initEvents.ts— wirehandleKeyboardVisibilityto theresizeevent alongside the existingupdateSizelistener, with matching teardown in cleanup.src/e2e/puppeteer/__tests__/caret.ts— regression test in themobile onlyblock simulating a keyboard-open then Down-Arrow dismiss (viewport resize without blur), asserting the selection is cleared.Cross-platform safety
The handler is touch-gated (no-op on desktop), throttled, only acts when
isKeyboardOpen && cursor, and ignores rotation (currentWidth === lastViewportWidth). On iOS the keyboard close fires blur first (Editable.tsxdispatcheskeyboardOpen({ value: false })), so the resize handler runs as a no-op there.