Phenomenon
Pressing Undo while Korean IME composition is active in a contenteditable element removes more text than expected, including characters that were committed before the current composition.
Reproduction example
- Focus the editable area.
- Type a short word and finalize it (e.g., “한”).
- Activate Korean IME and start composing another word (e.g., “글”), but do not finalize it.
- Press Ctrl+Z (or the platform-specific Undo shortcut).
Observed behavior
- Both the active composition and previously committed characters are removed
- The event log shows a sequence of
beforeinput/inputevents that do not map cleanly to user intent - Undo granularity is incorrect
Expected behavior
- Undo reverts only the last committed edit step, or at least behaves in the same way as native controls in the same environment
- Active composition should be cancelled, but previously committed text should remain
Browser Comparison
- Chrome: Undo may remove more than expected during composition
- Edge: Similar to Chrome
- Firefox: May have different undo behavior
- Safari: Not applicable on Windows
Notes and possible direction for workarounds
- This behavior can interfere with predictable text editing and undo/redo stacks
- Monitor composition state when handling undo operations
- Consider implementing custom undo/redo logic for better control