Case ce-0235-chinese-ime-pinyin-table-ios-safari-en · Scenario scenario-ime-pinyin-visible-safari

IME composition shows Pinyin in table cells on iOS Safari

OS: iOS 16+ Device: Mobile (iPhone/iPad) Any Browser: Safari 16+ Keyboard: Chinese (IME) - iOS Chinese Input Status: draft
composition ime table chinese ios mobile

현상

In iOS Safari, when typing Chinese IME text in table cells (<td>), pressing Space to confirm composition causes both raw Pinyin buffer and confirmed Chinese characters to appear together.

재현 예시

  1. Tap on a table cell (<td> element) to focus.
  2. Activate Chinese IME (iOS Chinese keyboard).
  3. Type Pinyin “nihao” (for Chinese characters “你好”).
  4. Press Space to confirm composition.

관찰된 동작

  • Duplicate text: Pinyin “nihao” and Chinese “你好” appear together → “nihao 你好”
  • Table cells only: Behavior does not occur in paragraph elements (<p>, <div>)
  • iOS Safari specific: Similar to desktop Safari but on mobile devices
  • Works in Chrome/Firefox: Other browsers do not exhibit this bug

예상 동작

  • Pinyin buffer (“nihao”) should NOT be visible
  • Only confirmed Chinese characters (“你好”) should appear

참고사항 및 가능한 해결 방향

  • Use div instead of td: Replace <td> with <div> for editable content when possible
  • Force DOM cleanup: Remove Pinyin text after composition completes
  • Avoid direct editing in table cells: Use modal or overlay for table cell editing

코드 예시

const cell = document.querySelector('td[contenteditable]');
let isComposing = false;

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

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

cell.addEventListener('keydown', (e) => {
  if (isComposing && e.key === ' ') {
    e.preventDefault();
    // Let IME complete naturally
  }
});
Before
Empty table cell
Step 1: Type Pinyin 'nihao'
nihao
Typing Pinyin with IME (candidates shown)
vs
✅ Expected
你好
Expected: Only Chinese characters should remain

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: iOS 16+
Device: Mobile (iPhone/iPad) Any
Browser: Safari 16+
Keyboard: Chinese (IME) - iOS 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.

Comments & Discussion

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