Case ce-0231-korean-ime-focus-blur-safari · Scenario scenario-ime-composition-focus-change

Unexpected behavior when moving focus to another textbox during IME composition (Safari)

OS: macOS 13+ Device: Desktop (Mac) Any Browser: Safari 17+ Keyboard: Korean (IME) - macOS Korean Input Method Status: draft
composition ime focus blur korean safari webkit

Phenomenon

In Safari, when composing text with Korean IME, moving focus to another textbox causes the composition to not properly terminate, and WebKit-specific issues may occur.

Reproduction example

  1. Focus the first contenteditable element.
  2. Activate macOS Korean IME.
  3. Start composing a character (e.g., ‘나’ = ㅎ + ㄴ).
  4. Before composition completes (after typing initial consonant ㅎ), click the second textbox or move focus using a button.

Observed behavior

  • Jamo transfer phenomenon: The jamo ‘ㅎ’ may appear not only in the first field but also in the second field.
  • WebKit focus issues: WebKit tends to maintain focus even after external clicks, so focus may not properly move.
  • selection addRange failures: In Safari, selection.addRange() may not work as intended (related scenario: selection-addrange-safari-fail).
  • compositionend uncertainty: compositionend event fires, but the composition state is not fully cleaned up.

Expected behavior

  • Composition should fully terminate and the final character (‘나’) should be committed only to the first field.
  • Focus should cleanly move to the second field.
  • The composition state in the first field should be completely cleaned up.

Notes and possible direction for workarounds

  • Understand WebKit focus quirks: Recognize that Safari/WebKit focus management may differ from other browsers.
  • Use forced blur: Explicitly call editor1.blur() before moving focus to force IME state termination.
  • Check CSS user-select: Verify that -webkit-user-select: text; is properly set (related scenario: user-select-breaks-safari).
  • Selection API caution: Safari may have issues with selection.addRange(), so consider alternative selection setting methods.

Code example

let isComposing = false;

const editor1 = document.querySelector('div[contenteditable]:nth-child(1)');
const editor2 = document.querySelector('div[contenteditable]:nth-child(2)');

editor1.addEventListener('compositionstart', () => {
  isComposing = true;
});

editor1.addEventListener('compositionend', () => {
  isComposing = false;
  // Safari-specific: force blur to terminate IME state
  setTimeout(() => {
    editor1.blur();
    editor2.focus();
  }, 150);
});

// On button click
document.querySelector('button').addEventListener('click', () => {
  if (!isComposing) {
    editor2.focus();
  } else {
    alert('IME input in progress. Please wait for completion.');
  }
});
Before
Composing '나' with Korean IME
❌ After (Bug)
Jamo 'ㅎ' remains in first field and also appears in second field
vs
✅ Expected
Composition completes, cursor exists only in second field

Browser compatibility matrix

This matrix shows which browser and OS combinations have documented cases for this scenario. The current case is highlighted. Click on a cell to view other cases.

Current case
Confirmed
Draft
No case documented

All variants (detailed table)

Complete list of all cases for this scenario with full environment details.

Case OS Device Browser Keyboard Status
ce-0229-korean-ime-focus-blur-chrome Windows 10/11 Desktop or Laptop Any Chrome 120+ Korean (IME) - Microsoft IME draft
ce-0230-korean-ime-focus-blur-firefox Windows 10/11 Desktop or Laptop Any Firefox 120+ Korean (IME) - Microsoft IME draft
ce-0231-korean-ime-focus-blur-safari macOS 13+ Desktop (Mac) Any Safari 17+ Korean (IME) - macOS Korean Input Method draft

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: macOS 13+
Device: Desktop (Mac) Any
Browser: Safari 17+
Keyboard: Korean (IME) - macOS Korean Input Method
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.

Comments & Discussion

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