lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Typing after pasting a PageBreak is a no-op in Safari

Open mayrang opened this issue 5 months ago • 0 comments

Lexical version: 0.45.0 (current main, reproducible since the PageBreakNode landed)

Steps To Reproduce

  1. Open the Lexical playground in Safari (macOS).
  2. In an empty paragraph, type / and pick "Page break" from the menu.
  3. Click the inserted page-break to select it (NodeSelection), then Cmd+C.
  4. Move the caret to another empty paragraph and Cmd+V.
  5. The horizontal caret appears right after the pasted page-break.
  6. Type any character.

https://github.com/user-attachments/assets/bf3c6cf5-4629-414c-9611-59d72170878d

Link to code example: reproducible directly on https://playground.lexical.dev

The current behavior

In Safari, step 6 is a no-op — no character is inserted, no paragraph appears, the caret stays put. Arrow Up/Down and Enter at that caret are also no-ops. beforeinput and input never fire on the contentEditable root (verified by attaching listeners directly).

The pasted EditorState is fine: root ends in [..., page-break, page-break] with a RangeSelection whose anchor and focus are both { key: root, offset: N, type: element }. The lazy paragraph-on-typing path (\$transferStartingElementPointToTextPoint) never runs because beforeinput never reaches Lexical.

A horizontal rule pasted the same way works in Safari — same EditorState shape, same root element point selection, the only difference is the DOM element itself (<hr> vs <figure contenteditable=\"false\">).

The expected behavior

Same as Chrome and Firefox: typing at the caret right after the pasted page-break lazily creates a trailing paragraph and the character is inserted.

Impact of fix

Affects every Safari user who copies and pastes a page-break in the playground (and any consumer of `PageBreakNode` that exposes paste/duplicate UX). Insert-via-menu works because `$insertNodeToNearestRoot` splits around the caret — the gap is only on the paste path. Severity: moderate — the document state is intact, but typing is blocked until the user clicks elsewhere and back.

mayrang avatar Jun 18 '26 05:06 mayrang