Phenomenon
When composing Arabic text with IME in a contenteditable element, pressing Escape cancels the composition and loses the composed text including character joining. This can interfere with UI interactions that use Escape for cancellation or closing dialogs.
Reproduction example
- Focus the editable area (e.g., in a modal dialog or dropdown).
- Activate Arabic IME.
- Start composing Arabic text with character joining (e.g., “مرحبا”).
- Press Escape to close the dialog or cancel an action.
Observed behavior
- The compositionend event fires with incomplete data
- The composed text including character joining is lost
- Escape may trigger both composition cancellation and other UI actions
- No recovery mechanism for lost composition
Expected behavior
- Composition should be handled gracefully when Escape is pressed
- Composed text including character joining should not be lost
- Escape key behavior should be consistent and predictable
Browser Comparison
- Firefox: Escape may cancel composition
- Chrome: May have different Escape key behavior during composition
- Edge: Similar to Chrome
- Safari: Not applicable on Windows
Notes and possible direction for workarounds
- Prevent Escape during active composition if composition preservation is critical
- Consider committing composition before allowing Escape
- Handle Escape key events carefully during composition, especially in modal contexts and with RTL text