You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: [lexical] Typing with a toggled format inside a segmented text node formats the whole node #9833
RangeSelection.insertText with a collapsed selection inside a segmented text node, after a format was toggled on the caret, makes the whole node bold (or whatever the toggled format is), not just the typed text.
Repro (headless, no collaboration): a paragraph with zero and a segmented text node one two; caret at offset 4 of the segmented node (before two); selection.formatText('bold'); selection.insertText('new '). Result: zero plain and one new two bold. Expected: only new bold.
Cause: the segmented-node branch of $insertText (packages/lexical/src/LexicalSelection.ts, the anchorNode.isSegmented() && offset !== 0 && offset !== anchorSize case) replaces the node with a normal text node and calls replacement.setFormat(format) / setStyle(style) with the selection's format and style (and setMode('normal').setFormat(format).setStyle(style) while composing), so the existing text takes them; the recursive insertText then sees the selection's format equal to the node's and inserts without splitting. Keeping the node's own format and style on the replacement would let the recursive call split as it does for a normal node.
Found by a collaboration soak, but it is the same on its own.
Activity
[lexical] Bug Fix: Only format typed text when inserting into segment…