Commit ae1ab7b
zenggenfa
fix(slate-react): prevent premature flush during composition for Android handwriting input
Fixes #5979
On Android devices, handwriting input on empty lines triggers childList mutations
when creating new DOM structure for the first character. These mutations get
restored by RestoreDOM during React re-render, which interrupts the IME composition
session and causes premature stroke commits (e.g., writing '我' produces '一我').
The fix adds a targeted check in flush() to skip flushing only when:
1. Currently in composition (IS_COMPOSING is true)
2. Cursor is at the first character of an empty line
This preserves normal onChange behavior for other scenarios while preventing
the handwriting issue on empty lines.1 parent addf0c5 commit ae1ab7b
File tree
2 files changed
+38
-0
lines changed- .changeset
- packages/slate-react/src/hooks/android-input-manager
2 files changed
+38
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
126 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
127 | 155 | | |
128 | 156 | | |
129 | 157 | | |
| |||
0 commit comments