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-selection] $wrapNodes over a box that holds text directly next to its blocks can reorder text or never return #9665
Lexical version: main at c0c7e42 (@lexical/selection), and with #9664.
Steps To Reproduce
An editor with QuoteNode and a plain block element class that declares no structure (no NodeStructureExtension), Box, holding text directly next to its blocks:
Never returns: root(Box(p("t0"), Box(p("t1"), p("t2"), "t3"), p("t4"), p("t5")), p("t6")), selection from the outer box at offset 4 (its end, element point) to p("t1") at offset 1 (element point), then $wrapNodes(selection, () => $createQuoteNode()). The update never returns: the new elements are inserted next to a node that is moved into one of them (a parent cycle).
Reorders text: root(Box(p("t0"), "t1", Box("t2", <hr>, p("t3"), p("t4"))), p("t5")), selection from "t0" offset 1 to p("t4") offset 0 (element point): after $wrapNodes, the text reads t0, t1, t2, t4, t3, t5.
Link to code example: packages/lexical-selection/src/__tests__/unit/WrapNodesBlockLeaf.test.ts in #9664 (property: with text directly in a box, pinned as test.fails): a seeded property over 500 random documents of paragraphs, horizontal rules, boxes and text directly in a box, with random ranges. On main 8 documents fail (4 never return), with #9664 7 (3 never return), all among main's.
The current behavior
When a box that is not a block container holds inline content directly next to blocks, $wrapNodes takes the box for the block of that content and moves all its children into one new element; the place it inserts the new elements can then be inside that element (a cycle, the update never returns), or after content that moved before it (text out of order).
The expected behavior
The call returns, and every text stays, in its order.
Activity
[lexical-selection] Bug Fix: Wrap a block leaf on its own only where …
[lexical-selection] Bug Fix: Keep mixed-block wrapping units from ove…
[lexical-selection] Chore: Cover mixed-block wrapping regressions
[lexical-selection] Chore: Add a changeset for mixed-block wrapping