์ผ€์ด์Šค ce-0233-chinese-ime-pinyin-heading-chrome-en-ko ยท ์‹œ๋‚˜๋ฆฌ์˜ค scenario-ime-duplicate-text-heading

IME composition causes duplicate Pinyin text in headings

OS: Windows 10/11 ๊ธฐ๊ธฐ: Desktop Any ๋ธŒ๋ผ์šฐ์ €: Chrome 120+ ํ‚ค๋ณด๋“œ: Chinese (IME) - Windows Chinese Input ์ดˆ์•ˆ
compositionimeheadingchinesewebkitduplicate-text

ํ˜„์ƒ

In Chrome (Blink/WebKit), when using Chinese IME to input text in heading elements (<h1>-<h6>), pressing Space to confirm composition causes both the raw Pinyin buffer and the confirmed characters to appear together.

์žฌํ˜„ ์˜ˆ์‹œ

  1. H2 or other heading element is focused.
  2. Windows Chinese IME is activated.
  3. Type Pinyin โ€œnihaoโ€ (for Chinese characters โ€œไฝ ๅฅฝโ€).
  4. Press Space to confirm composition.

๊ด€์ฐฐ๋œ ๋™์ž‘

  • Duplicate text: Pinyin โ€œnihaoโ€ and Chinese โ€œไฝ ๅฅฝโ€ appear together โ†’ โ€œnihao ไฝ ๅฅฝโ€
  • Heading elements only: Behavior does not occur in paragraph elements (<p>, <div>)
  • WebKit/Chromium issue: Similar to Safari behavior
  • Firefox unaffected: Firefox does not exhibit this bug

์˜ˆ์ƒ ๋™์ž‘

  • Pinyin buffer (โ€œnihaoโ€) should NOT be visible
  • Only confirmed Chinese characters (โ€œไฝ ๅฅฝโ€) should appear

์ฐธ๊ณ ์‚ฌํ•ญ ๋ฐ ๊ฐ€๋Šฅํ•œ ํ•ด๊ฒฐ ๋ฐฉํ–ฅ

  • Use semantic paragraphs: Replace <h1>-<h6> with <p> + CSS styling for headings
  • DOM cleanup in compositionend: Remove Pinyin text after composition completes
  • Intercept Space key: Prevent Space key during composition to let IME handle naturally

์ฝ”๋“œ ์˜ˆ์‹œ

const heading = document.querySelector('h2[contenteditable]');
let isComposing = false;

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

heading.addEventListener('compositionend', () => {
  isComposing = false;
  // DOM cleanup: remove Pinyin
  setTimeout(() => {
    const text = heading.textContent;
    const cleaned = text.replace(/[a-z]+/g, '');
    heading.textContent = cleaned;
  }, 0);
});

heading.addEventListener('keydown', (e) => {
  if (isComposing && e.key === ' ') {
    e.preventDefault();
    // Let IME complete naturally
  }
});

์ด ์‹œ๋‚˜๋ฆฌ์˜ค์˜ ๋ณ€ํ˜•

์ผ€์ด์Šค OS ๋ธŒ๋ผ์šฐ์ € ์ƒํƒœ
ce-0232-chinese-ime-pinyin-heading-safari-ko macOS 13+ Safari 17+ ์ดˆ์•ˆ
ce-0233-chinese-ime-pinyin-heading-chrome-en-ko Windows 10/11 Chrome 120+ ์ดˆ์•ˆ

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: Windows 10/11
Device: Desktop Any
Browser: Chrome 120+
Keyboard: Chinese (IME) - Windows Chinese Input
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.