Phenomenon
When composing Vietnamese text with IME in a contenteditable element, pressing Enter cancels the composition and may lose diacritic marks (accents) that were being composed. The caret moves to the next line but the last composed character or diacritics may be lost.
Reproduction example
- Focus the editable area.
- Activate Vietnamese IME (Telex or VNI input method).
- Type Vietnamese text with diacritics (e.g., “xin chào”).
- Press Enter to insert a new line during composition.
Observed behavior
- The compositionend event fires with incomplete data
- The caret moves to the next line
- Diacritic marks may be lost
- Base letters and diacritics may not be properly combined
Expected behavior
- The IME finalizes the current composition before inserting a line break
- All diacritic marks should be preserved
- The last composed character should remain in the DOM text content
Browser Comparison
- Edge: May cancel composition when Enter is pressed
- Chrome: Similar to Edge
- Firefox: May have different behavior
- Safari: Not applicable on Windows
Notes and possible direction for workarounds
- Observe the sequence of
beforeinput,compositionend, andinputevents - Check whether diacritics are properly preserved
- A possible workaround is to intercept Enter on
keydownand prevent the default behavior while waiting for composition to complete