Phenomenon
A data-loss bug exists in high-version Chromium for Android (131+) when mixing complex IME composition with emoji input. If a user is in the middle of typing a character (especially in CJK or Thai) and switches to the emoji keyboard to insert an icon, the browser triggers a compositionend event with data: "" or null. This effectively wipes out the currently composing character instead of finalizing it.
Reproduction Steps
- Open a
contenteditableeditor on Android. - Use a CJK IME (like Korean Gboard).
- Type a character so that the underline is visible (active composition).
- Without hitting Space or Enter, open the Emoji menu and select an emoji.
- Check if the composing character remains in the DOM.
Observed Behavior
- Buffer Wipeout: The
compositionupdatetext disappears from the DOM. - Missing Events: The browser fails to send an
insertReplacementTextorinsertTextevent for the ghost-character. - Inconsistent ‘beforeinput’:
beforeinputtypes for the emoji are fired, but no events are fired to “clean up” the previous session.
Impact
- Information Loss: Users lose the last syllable of their sentence if they punctuate with an emoji.
- Frustration: Users must switch back keyboards, re-type the character, and then re-add the emoji.
Browser Comparison
- Chrome for Android (131+): Confirmed regression.
- iOS Safari: Correctly flushes the composition buffer before inserting the emoji.
- Firefox for Android: Generally stable; correctly handles the keyboard switch.
References & Solutions
Mitigation: manual flush
Developers can watch for a keyboard type change (if detectable) or manually capture the last compositionupdate value. If a focus-like or input-mode change occurs while isComposing is true, manually insert the cached text.