Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Has failing tests |
…widget itself A columns layout that is the only top-level node survived select-all + delete: the widget stayed behind holding two empty layout items instead of being removed (meta#6938). A paragraph before the widget made it work, which is the tell. $selectAll sets its points at the element level and then normalizes them down towards text points. When every point descends into the same top-level shadow root, the result stops describing "select everything" and starts describing "select the text inside the widget" - the range never covers the widget itself, so deleting only empties it. $normalizeSelectionForSelectAll keeps the element-level points in exactly that case. A selection that merely starts in a shadow root, such as a select-all anchored in a leading table, normalizes as before: it already extends past the widget, so the widget is covered either way, and the table cell observer keeps seeing the cell selection that Tables.spec.mjs asserts. getTopLevelElement stops at the nearest shadow root, which for a nested widget is an inner scope (a layout item rather than the layout container), so the comparison walks out to the child of the RootNode instead. $removeTextFromCaretRange restores the empty paragraph when the removal empties the root, matching the result of deleting a document made of ordinary paragraphs. Fixes meta#6938
3f19a13 to
f2eafdc
Compare
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
|
Reworked this after CI caught a regression, and the new shape is smaller. The first version added a The distinguishing property is narrower than "the point would enter a shadow root". It is the whole range collapsing inside one top-level shadow root:
So the rule now lives in One detail worth flagging: Verification:
|
When a columns layout (or any shadow root) is the first node in the document, select-all followed by delete left the widget behind with empty columns. With a paragraph before it, the same gesture deleted correctly.
As @etrepum diagnosed in the issue, the cause is point normalization in
$selectAll.$normalizePointdescends element points toward the deepest text point, and it descends straight through shadow roots — so a selection spanning the whole document is rewritten into one scoped inside the widget, and the deletion that follows can no longer tell "select the widget" from "select the text in the widget".$normalizeSelectiontakes an opt-instopAtShadowRootflag, which$selectAllpasses. The descent stops before entering a shadow root, so select-all keeps element points at the container level. Select-all scoped inside a single column is unaffected, since that path never crosses a shadow root.That alone lets a select-all delete empty the root, which the existing
Issue8745Reprotest rightly forbids, so$removeTextFromCaretRangenow restores an empty paragraph when a removal leaves the root with no children.One thing I left out of scope: forward-Delete over a select-all still leaves the root empty, because
$ensureRootHasParagraph()only runs on the backward branch ofdeleteCharacter. That is pre-existing and generic — a lone decorator node behaves identically on unmodified main.Fixes #6938