Skip to content

fix: 🐛 fix android soft keyboard dismisses when mark and input#6027

Open
virgil1996 wants to merge 1 commit into
ianstormtaylor:mainfrom
virgil1996:fix/android-mark-input
Open

fix: 🐛 fix android soft keyboard dismisses when mark and input#6027
virgil1996 wants to merge 1 commit into
ianstormtaylor:mainfrom
virgil1996:fix/android-mark-input

Conversation

@virgil1996

Copy link
Copy Markdown

Description
On Android, after toggling a mark (e.g. bold) with a collapsed selection, the next keystroke could dismiss the soft keyboard and break caret placement. The Android input manager scheduled a follow-up selection using a point computed as if the character were inserted inside the same text leaf (path unchanged, offset + text.length). When editor.marks is set, Editor.insertText uses insertNodes (a new marked text node) rather than extending the current leaf, so that computed point could lie beyond the leaf length and overwrite the valid selection that insertNodes had already applied.
This change stops scheduling a second Transforms.select with that raw point: performAction already normalizes action.at with normalizePoint and updates the selection; the previous run() callback duplicated the select with incorrect coordinates for the marks/insertNodes case.

Issue
Fixes: #6022

Example

Before repair see #6022

After repair:
https://github.com/user-attachments/assets/20d0d15a-687e-4816-9e8d-6b0de32fac05

Context
In handleDOMBeforeInput, after storeDiff for an insertion, the code called
scheduleAction(() => Transforms.select(editor, { anchor: newPoint, focus: newPoint }), { at: newPoint }). flush runs Editor.insertText for the diff; with active marks, Slate’s insertText inserts a new text node and sets the selection to the end of that node. performAction then runs: it first selects using normalizePoint(editor, newPoint), which maps an “past end of leaf” offset onto the correct following text node. Immediately after, action.run() called Transforms.select again with the un-normalized newPoint, which is invalid when the insert was a sibling node. Replacing the callback with a no-op keeps selection handling solely in the normalizePoint path inside performAction.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot

changeset-bot Bot commented Mar 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b8eb398

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

[Android] Soft keyboard dismisses and cursor jumps when typing after toggling a mark on a collapsed selection

1 participant