Phenomenon
When composing Thai text with IME in a contenteditable element, pressing Enter cancels the composition and may lose tone marks or vowel marks that were being composed. The caret moves to the next line but the last composed character or combining marks may be lost.
Reproduction example
- Focus the editable area.
- Activate Thai IME.
- Type Thai text with tone marks and vowel marks (e.g., “สวัสดี”).
- 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
- Tone marks or vowel marks may be lost
- Combining characters may not be properly committed
Expected behavior
- The IME finalizes the current composition before inserting a line break
- All combining characters (tone marks, vowel marks) should be preserved
- The last composed character should remain in the DOM text content
Browser Comparison
- Chrome: May cancel composition when Enter is pressed
- Edge: Similar to Chrome
- 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 combining characters are properly preserved
- A possible workaround is to intercept Enter on
keydownand prevent the default behavior while waiting for composition to complete