Scenario

Korean IME composition causes editor crash (Firefox)

On Firefox with Windows 10 and Korean IME, specific key combination during IME composition causes the editor to crash. The crash occurs when typing certain sequences with the Korean IME.

ime
Scenario ID
scenario-ime-korean-crash-firefox

Details

On Firefox with Windows 10 and Korean IME, specific key combination sequences during IME composition can cause the contenteditable editor to crash unexpectedly.

Problem Description

This issue occurs specifically when:

  1. User is on Windows 10
  2. Using Firefox browser
  3. Using Korean IME (e.g., Microsoft IME)
  4. Typing specific key sequences during IME composition

Crash Scenario

Based on the GitHub issue, the crash sequence is:

  1. Enable Korean IME
  2. Type ㅀ (press ‘f’, then ‘g’ on QWERTY keyboard)
  3. Hit Enter to confirm composition
  4. Press Ctrl+Shift+Home

Expected Behavior

  • Editor should handle the key sequence normally
  • No crash should occur
  • IME composition should complete or be interrupted gracefully

Actual Behavior (Firefox Bug)

  • Editor crashes: The contenteditable editor completely crashes
  • JavaScript execution stops
  • User must reload the page

Affected Browsers

  • Firefox (Windows 10, with Korean IME) - Issue confirmed
  • Chrome - Does NOT exhibit this crash
  • Safari - Does NOT exhibit this crash

Affected Languages

  • Korean IME (Microsoft IME on Windows)
  • Similar issues may occur with other IMEs

Root Cause

Firefox’s IME handling appears to have a race condition or memory corruption when:

  1. Processing specific key sequences (like Ctrl+Shift+Home) during active IME composition
  2. The IME state management and editor DOM state get out of sync
  3. Internal selection/range calculation crashes when conflicting operations occur

Workarounds

  1. Prevent Ctrl+Shift+Home during composition:

    let isComposing = false;
    
    editor.addEventListener('compositionstart', () => {
      isComposing = true;
    });
    
    editor.addEventListener('keydown', (e) => {
      if (isComposing && e.ctrlKey && e.shiftKey && e.key === 'Home') {
        e.preventDefault();
        // Prevent problematic key combination during IME
      }
    });
    
    editor.addEventListener('compositionend', () => {
      isComposing = false;
    });
  2. Try-catch around critical operations:

    editor.addEventListener('input', (e) => {
      try {
        // Handle input event
      } catch (error) {
        console.error('Input error:', error);
        // Recover gracefully
      }
    });
  3. Use try-finally for cleanup:

    try {
      // IME operations
    } finally {
      // Always cleanup state
    }

References

Scenario flow

Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.

React Flow mini map

Variants

Each row is a concrete case for this scenario, with a dedicated document and playground.

Case OS Device Browser Keyboard Status
ce-0261-korean-ime-crash-firefox-en Windows 10 Desktop Any Firefox 120+ Korean (IME) - Microsoft IME draft

Cases

Open a case to see the detailed description and its dedicated playground.

Related Scenarios

Other scenarios that share similar tags or category.

Tags: composition, ime

beforeinput and input events have different inputType values

During IME composition or in certain browser/IME combinations, the beforeinput event may have a different inputType than the corresponding input event. For example, beforeinput may fire with insertCompositionText while input fires with deleteContentBackward. This mismatch can cause handlers to misinterpret the actual DOM change and requires storing beforeinput's targetRanges for use in input event handling.

1 case
Tags: composition, ime

Selection mismatch between beforeinput and input events

The selection (window.getSelection()) in beforeinput events can differ from the selection in corresponding input events. This mismatch can occur during IME composition, text prediction, or when typing adjacent to formatted elements like links. The selection in beforeinput may include adjacent formatted text, while input selection reflects the final cursor position.

1 case
Tags: composition, ime

getTargetRanges() returns empty array in beforeinput events

The getTargetRanges() method in beforeinput events may return an empty array or undefined in various scenarios, including text prediction, certain IME compositions, or specific browser/device combinations. When getTargetRanges() is unavailable, developers must rely on window.getSelection() as a fallback, but this may be less accurate.

1 case

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.