Case ce-0575-prosemirror-safari-empty-table-leak · Scenario scenario-table-composition-leaks

ProseMirror: Text moves out of empty table cell in Safari

OS: macOS 15.2 Device: Desktop Any Browser: Safari 18.2 Keyboard: Japanese IME Status: confirmed
prosemirror safari table composition regression

Phenomenon

In late 2025 (affecting prosemirror-view prior to 1.41.5), a specific interaction with Safari 18’s improved but still buggy composition engine was identified. When composing Japanese/Korean text in a completely empty <td>, the Committed text “leaks” out to the parent container. This happens because WebKit’s selection mapping fails to find a stable anchor within the empty cell after the temporary composition nodes are removed.

Reproduction Steps

  1. Use ProseMirror-view < 1.41.5.
  2. Create a document with an empty table cell.
  3. Open in Safari 18.2+.
  4. Focus the cell and type using a CJK IME.
  5. Press Enter to confirm.

Observed Behavior

  • DOM Leaking: The text appears outside the table at the document level.
  • Inconsistent State: ProseMirror’s EditorState still thinks the cursor is in the cell, or it may crash if the mutation happens in an unmanaged area.

Expected Behavior

The text should stay within the <td> boundaries.

Browser Comparison

  • Safari 18.2: High reproduction rate.
  • Chrome/Firefox: Correct behavior.

References & Solutions

Mitigation: The “Invisible Content” Hack

ProseMirror fixed this in v1.41.5 by ensuring that empty table cells always contain at least a <br> or a zero-width space during selection to anchor the WebKit engine.

/* ProseMirror-view internal-like fix */
function fixEmptyCell(dom) {
  if (isSafari && dom.nodeName === 'TD' && !dom.firstChild) {
    dom.appendChild(document.createElement('br'));
  }
}
Step 1: Focus Empty TD
|
Caret is in an empty cell managed by ProseMirror-view.
Step 2: Composition
...あ|
IME composition session starts. ProseMirror may inject temporary widget nodes.
vs
✅ Expected
아|
Expected: Text remains inside the cell and ProseMirror updates its document model correctly.

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-0566-safari-table-cell-composition-leak macOS 14.4 Desktop Any Safari 17.4 Japanese IME confirmed
ce-0575-prosemirror-safari-empty-table-leak macOS 15.2 Desktop Any Safari 18.2 Japanese IME confirmed

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 15.2
Device: Desktop Any
Browser: Safari 18.2
Keyboard: Japanese IME
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.