Skip to content

fix: prevent Android IME first character duplication on empty nodes#6020

Open
joyboyguo-sketch wants to merge 1 commit into
ianstormtaylor:mainfrom
joyboyguo-sketch:fix/android-ime-first-char-duplication
Open

fix: prevent Android IME first character duplication on empty nodes#6020
joyboyguo-sketch wants to merge 1 commit into
ianstormtaylor:mainfrom
joyboyguo-sketch:fix/android-ime-first-char-duplication

Conversation

@joyboyguo-sketch

@joyboyguo-sketch joyboyguo-sketch commented Mar 11, 2026

Copy link
Copy Markdown

Description
Fixes a bug introduced with #5983

When the cursor is positioned at an empty text node, Android IME treats the transition from empty to non-empty as a structural change and restarts composition, causing the first character to be duplicated.

Fix by inserting a zero-width space (U+200B) at the start of composition when the current text node is empty. This makes the node appear non-empty to the IME, preventing the composition restart. The placeholder is automatically cleaned up from the AST after compositionEnd, keeping the document state clean.

Fixes: Android IME first character duplication issue

Issue
Fixes: (link to issue)
#5983

When the cursor is positioned at an empty text node, Android IME
treats the transition from empty to non-empty as a structural change
and restarts composition, causing the first character to be duplicated.

Fix by inserting a zero-width space (U+200B) at the start of composition
when the current text node is empty. This makes the node appear non-empty
to the IME, preventing the composition restart. The placeholder is
automatically cleaned up from the AST after compositionEnd, keeping
the document state clean.

Fixes: Android IME first character duplication issue
@changeset-bot

changeset-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cc0a590

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@tomdyqin

Copy link
Copy Markdown

good!it works for me!

@12joan

12joan commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

This fixes the issue for me on Gboard, but it's still present on Samsung Keyboard 3.3.23.33.

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.

3 participants