fix: Fix: Chinese IME Backspace bug。misses first onChange,double-fire…#5985
Open
wljray wants to merge 6 commits intoianstormtaylor:mainfrom
Open
fix: Fix: Chinese IME Backspace bug。misses first onChange,double-fire…#5985wljray wants to merge 6 commits intoianstormtaylor:mainfrom
wljray wants to merge 6 commits intoianstormtaylor:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 7682d36 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
dylans
requested changes
Dec 9, 2025
Collaborator
There was a problem hiding this comment.
Can we please remove the comments for more obvious things? If you feel the comments are necessary I would prefer a variable for the conditional check that makes it clearer what condition is being met.
Also please add a changeset so that it will end up in a release.
Also please check our linting rules
add changeset fix-android-ime-delete.md
dylans
reviewed
Dec 16, 2025
| } else if (userMarks !== undefined) { | ||
| editor.marks = userMarks | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
I think removing this might have been unintentional?
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.
Problem
On Android devices with Chinese IME (Input Method Editor), there's a bug with the delete/backspace behavior:
onChangeonChangetwiceThis causes issues with:
Root Cause
The issue is in
android-input-manager.ts:Issue 1:
storeDiffdoesn't schedule flushWhen
deleteContentBackwardstores a diff viastoreDiff(), the diff is stored but never flushed. The flush only happens when:scheduleAction()is called (which setssetTimeout(flush))compositionEndevent firesSo the first delete stores a diff but doesn't trigger flush → no
onChange.Issue 2: Duplicate
onChangeon flushIn the
flush()function, after processing diffs:Editor.deleteFragment()is called → triggersonChangeviaapply()→Promise.resolve().then()flush(),editor.onChange()is called again ifuserMarks !== undefinedSince
editor.markscan benull, andnull !== undefinedistrue, this causes a duplicateonChangecall.Solution
Fix 1: Schedule flush after storing diff
Add
scheduleFlush()calls at the end ofstoreDiff()to ensure stored diffs are processed and triggeronChange:Fix 2: Avoid duplicate onChange
Only call
editor.onChange()when marks actually changed:Testing
Steps to reproduce (before fix):
After fix:
onChangeeventChecklist
ChangeList
packages/slate-react/src/hooks/android-input-manager/android-input-manager.tsDiff