Type Editor / @type-editor/dom-change-util / browser-hacks/is-android-enter-suggestion-quirk / isAndroidEnterSuggestionQuirk
Function: isAndroidEnterSuggestionQuirk()
function isAndroidEnterSuggestionQuirk(
$from,
$to,
inlineChange,
parse,
change,
): boolean;Defined in: browser-hacks/is-android-enter-suggestion-quirk.ts:41
Checks if the Android virtual keyboard enter-and-pick-suggestion quirk is happening.
Android's virtual keyboard has a feature where after pressing Enter, it can suggest words or corrections. During this process, Android sometimes:
- Fires a DOM mutation that creates the new paragraph
- THEN moves the selection to the new paragraph
However, ProseMirror cleans up the DOM selection during step 1, causing Android to give up on step 2, leaving the cursor in the wrong place (issue #1059).
This function detects that specific sequence by checking:
- Running on Android
- Change is not inline (block-level change)
- Start and end are in different blocks ($from.start() !== $to.start())
- End position is at the very start of its parent ($to.parentOffset === 0)
- Both positions are at the same depth
- Selection exists and is collapsed (anchor === head)
- Selection is at the end of the change (head === change.endA)
When detected, the code drops the new paragraph from the change and dispatches a simulated Enter key event instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
$from | ResolvedPos | Start position in parsed document (resolved position) |
$to | ResolvedPos | End position in parsed document (resolved position) |
inlineChange | boolean | Whether the change is within inline content |
parse | ParseBetweenResult | Parsed document information including selection state |
change | DocumentChange | The detected document change |
Returns
boolean
True if this matches the Android enter-suggestion quirk pattern, false otherwise