Skip to content

[lexical][lexical-table] Bug Fix: selection and caret state at block and shadow-root boundaries - #9058

Merged
etrepum merged 9 commits into
meta:mainfrom
LeSingh1:consol/core-selection-caret
Aug 30, 2026
Merged

etrepum merged 9 commits into
meta:mainfrom
LeSingh1:consol/core-selection-caret

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Seven related core defects share one story: a RangeSelection or a block cursor
ends up pointing at the wrong place, whenever the caret crosses a block, shadow-root or inline
boundary — plus the two places where the surrounding machinery leaks that same
boundary confusion into the DOM. All of the source changes are in
packages/lexical; lexical-table and lexical-playground only gain tests.

Caret at a block or shadow-root boundary

  • A block cursor sitting between two shadow-root ElementNodes (a table, or a
    slot-bearing card) ignored Backspace and Delete entirely. deleteCharacter
    in LexicalSelection.ts only removed an adjacent block DecoratorNode; for
    an ElementNode host the caret walk descended into it as a ChildCaret and
    bailed out at the shadow root. It now removes the adjacent node when
    $needsBlockCursorBeside reports one, leaving decorators to the existing
    branch so isIsolated() is still honoured. (Bug: The block cursor between ElementNodes does not delete the node #8939)
  • Forward delete in an empty block immediately before a table did nothing.
    forwardDeletion stops at an adjacent shadow root so its content is never
    merged into the anchor block — but when that block is empty there is nothing
    to merge. deleteCharacter now falls through to the caret walk in exactly
    that case, removing the empty block and leaving the table in place, which is
    what backward delete already did. Restricted to a shadow root that is a
    sibling of the anchor block, so forward delete at the end of a table cell
    still bails out. (Bug: Delete key does not delete empty line before a table #8075)
  • Select-all over a document whose only top-level node is a shadow-root widget
    normalized both points down into the widget, so the range described "the text
    inside the widget" rather than "everything" and a delete emptied the widget in
    place instead of removing it. $normalizeSelectionForSelectAll in
    LexicalUtils.ts keeps the element-level points when both points resolve into
    the same top-level shadow root; a select-all that merely starts in one still
    normalizes as before. $removeTextFromCaretRange in caret/LexicalCaretUtils.ts
    restores the empty paragraph the root would otherwise be left without. (Bug: Columns Layout if first node deletion is incorrect #6938)
  • Pasting inline content with the caret inside an inline ElementNode that
    cannot be split put the content after the whole node instead of at the caret.
    An ElementNode is split by moving its trailing children into whatever
    insertNewAfter() returns, and the base-class default returns null.
    $splitNodeAtPoint and $removeTextAndSplitBlock in LexicalSelection.ts
    gained a stopAtUnsplittableInline flag and now return
    [container, offset], so the all-inline branch of insertNodes inserts into
    the node the walk stopped on. (Bug: Pasting text from the clipboard into a CustomElementNode does not work properly #6477)

Stale format and style after the caret moves

DOM state left behind at the same boundaries

Test plan

Four new unit test files (Issue8939Repro, Issue6781Repro,
Issue6477Repro, Issue5307Repro under packages/lexical/src/__tests__/unit,
plus Issue6938Repro under packages/lexical-playground/__tests__/unit) and new
cases appended to the existing LexicalSelection.test.ts,
LexicalTableSelection.test.tsx and CardNode.test.ts — 21 new unit tests, each
of which fails on main and passes here. The link-toolbar undo fix (#6714) is
browser-only and is covered by a new case in the Playwright spec
packages/lexical-playground/__tests__/e2e/Links.spec.mjs, which runs in CI's
e2e job and cannot be executed locally. The three other e2e specs
(ClearFormatting, Indentation, KeyboardShortcuts) only drop the now-absent
style="" from their expected HTML, which is the visible effect of the #5307
fix; those also run in CI's e2e job.

Supersedes #8945, #8946, #8948, #8954, #8955, #8970, #8971, #8977, consolidated
per the review feedback on #9027 and #9035.

The implementation of #8817 was dropped from this PR, this feature is a behavior regression.

…and shadow-root boundaries

## Description

Eight related core defects share one story: a `RangeSelection` or a block cursor
ends up pointing at the wrong place, or carrying the format and style of the
place it just left, whenever the caret crosses a block, shadow-root or inline
boundary — plus the two places where the surrounding machinery leaks that same
boundary confusion into the DOM. All of the source changes are in
`packages/lexical`; `lexical-table` and `lexical-playground` only gain tests.

**Caret at a block or shadow-root boundary**

- A block cursor sitting between two shadow-root `ElementNode`s (a table, or a
  slot-bearing card) ignored Backspace and Delete entirely. `deleteCharacter`
  in `LexicalSelection.ts` only removed an adjacent block `DecoratorNode`; for
  an `ElementNode` host the caret walk descended into it as a `ChildCaret` and
  bailed out at the shadow root. It now removes the adjacent node when
  `$needsBlockCursorBeside` reports one, leaving decorators to the existing
  branch so `isIsolated()` is still honoured. (meta#8939)
- Forward delete in an empty block immediately before a table did nothing.
  `forwardDeletion` stops at an adjacent shadow root so its content is never
  merged into the anchor block — but when that block is empty there is nothing
  to merge. `deleteCharacter` now falls through to the caret walk in exactly
  that case, removing the empty block and leaving the table in place, which is
  what backward delete already did. Restricted to a shadow root that is a
  sibling of the anchor block, so forward delete at the end of a table cell
  still bails out. (meta#8075)
- Select-all over a document whose only top-level node is a shadow-root widget
  normalized both points down into the widget, so the range described "the text
  inside the widget" rather than "everything" and a delete emptied the widget in
  place instead of removing it. `$normalizeSelectionForSelectAll` in
  `LexicalUtils.ts` keeps the element-level points when both points resolve into
  the *same* top-level shadow root; a select-all that merely starts in one still
  normalizes as before. `$removeTextFromCaretRange` in `caret/LexicalCaretUtils.ts`
  restores the empty paragraph the root would otherwise be left without. (meta#6938)
- Pasting inline content with the caret inside an inline `ElementNode` that
  cannot be split put the content after the whole node instead of at the caret.
  An `ElementNode` is split by moving its trailing children into whatever
  `insertNewAfter()` returns, and the base-class default returns `null`.
  `$splitNodeAtPoint` and `$removeTextAndSplitBlock` in `LexicalSelection.ts`
  gained a `stopAtUnsplittableInline` flag and now return
  `[container, offset]`, so the all-inline branch of `insertNodes` inserts into
  the node the walk stopped on. (meta#6477)

**Stale format and style after the caret moves**

- Moving the selection through the node APIs left the old position's pending
  format and style on it, so the toolbar and the next insertion used stale
  formatting. `$internalCreateRangeSelection` already re-derives them for every
  selection change that originates in the DOM; the new
  `$internalRefreshSelectionFormatAndStyle` in `LexicalSelection.ts` does the
  same for `ElementNode.select()` and `TextNode.select()`. Landing on the same
  node is deliberately not a move — a format armed on a collapsed caret must
  survive being re-selected in place. (meta#8817)
- `RangeSelection.removeText` can leave the caret in a node it did not start in
  — backspacing an empty paragraph merges it into the end of the previous block
  — while keeping the format and style of the node it left. It now re-derives
  both from the node the caret landed on. (meta#6781)

**DOM state left behind at the same boundaries**

- Clearing the last theme class or the last inline declaration left `class=""`
  and `style=""` in the editor DOM: `classList.remove(...)` and
  `style.setProperty(prop, '')` do not remove the attribute once it is empty.
  The new `removeEmptyDOMAttribute` in `LexicalUtils.ts` is called from
  `setElementIndent` and `setElementFormat` in `LexicalReconciler.ts` and from
  `setTextThemeClassNames` and `TextNode.updateDOM`. (meta#5307)
- Pressing undo while focus is in a control outside the editor (the link
  toolbar's URL field) dispatches `historyUndo` at the editor root with no
  Lexical selection. `$handleBeforeInput` in `LexicalEvents.ts` returned without
  preventing the default, so the browser ran its native history over a
  Lexical-managed contenteditable and the editor state was then rebuilt from a
  DOM that was never in Lexical's history. It now prevents the default and
  dispatches `UNDO_COMMAND`/`REDO_COMMAND`; `@lexical/history` restores a whole
  editor state and needs no selection. (meta#6714)

## Test plan

Five new unit test files (`Issue8939Repro`, `Issue8817Repro`, `Issue6781Repro`,
`Issue6477Repro`, `Issue5307Repro` under `packages/lexical/src/__tests__/unit`,
plus `Issue6938Repro` under `packages/lexical-playground/__tests__/unit`) and new
cases appended to the existing `LexicalSelection.test.ts`,
`LexicalTableSelection.test.tsx` and `CardNode.test.ts` — 21 new unit tests, each
of which fails on `main` and passes here. The link-toolbar undo fix (meta#6714) is
browser-only and is covered by a new case in the Playwright spec
`packages/lexical-playground/__tests__/e2e/Links.spec.mjs`, which runs in CI's
e2e job and cannot be executed locally. The three other e2e specs
(`ClearFormatting`, `Indentation`, `KeyboardShortcuts`) only drop the now-absent
`style=""` from their expected HTML, which is the visible effect of the meta#5307
fix; those also run in CI's e2e job.

### Before

Source changes reverted, new tests kept:

```
$ npx vitest run --project unit packages/lexical/src packages/lexical-table packages/lexical-playground
 × clearing an element format removes the style attribute 74ms
 × clearing an element indent removes the style attribute 7ms
 × clearing a text style removes the style attribute 31ms
 × clearing the last text format removes the class attribute 8ms
 × selectStart() drops the format of the old position 202ms
 × selectEnd() picks up the format of the new position 31ms
 × selectStart() drops the style of the old position 25ms
 × selectEnd() picks up the style of the new position 4ms
 × merging into the previous block adopts that block text format and style 142ms
 × forward delete removes an empty block before a shadow root 13ms
 × block cursor between two Cards deletes one (isBackward: true) 9ms
 × block cursor between two Cards deletes one (isBackward: false) 5ms
 × forward delete removes an empty paragraph before a table 9ms
 × removes the widget when it is the first node 17ms
 × removes the widget when it is the first node via removeText 2ms
 × replaces the widget when typing over a select-all 21ms
 × pasted text is inserted at the caret inside the node 38ms
 × an inline node inserted at the caret goes inside the node 5ms
 × deletes the adjacent 'shadowRoot' (isBackward: true) 6ms
 × deletes the adjacent 'shadowRoot' (isBackward: false) 1ms
 × Backspace after the last shadow root deletes it 6ms

 Test Files  9 failed | 85 passed (94)
      Tests  21 failed | 1718 passed (1739)
```

### After

```
$ npx vitest run --project unit packages/lexical/src packages/lexical-table packages/lexical-playground

 Test Files  94 passed (94)
      Tests  1739 passed (1739)

$ npx tsc --noEmit -p .
(clean, exit 0)
```

Supersedes meta#8945, meta#8946, meta#8948, meta#8954, meta#8955, meta#8970, meta#8971, meta#8977, consolidated
per the review feedback on meta#9027 and meta#9035.
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@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.

@vercel

vercel Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 30, 2026 4:16pm
lexical-playground Ready Ready Preview Aug 30, 2026 4:16pm

Request Review

Comment on lines +377 to +378
expect($isRangeSelection(selection)).toBe(true);
(selection as RangeSelection).deleteCharacter(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect($isRangeSelection(selection)).toBe(true);
(selection as RangeSelection).deleteCharacter(false);
assert($isRangeSelection(selection));
selection.deleteCharacter(false);

if (!$isTableRowNode(row)) {
throw new Error('Expected a TableRowNode');
}
const cell = row.getFirstChildOrThrow<TableCellNode>();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use $assertNodeType - explicit generics are deprecated here

Comment on lines +440 to +443
const table = $getRoot().getFirstChild();
if (!$isTableNode(table)) {
throw new Error('Expected a TableNode');
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of code is shorter with $assertNodeType

@LeSingh1
LeSingh1 force-pushed the consol/core-selection-caret branch from 6ca5f1d to 5ef334c Compare August 16, 2026 19:51
@LeSingh1

Copy link
Copy Markdown
Contributor Author

All four applied in 5ef334c — $assertNodeType in place of the explicit generic and the throw-based narrowing, in both LexicalTableSelection.test.tsx and Issue5307Repro.test.ts, plus assert($isRangeSelection(...)) for the delete helper.

Two notes: assert comes from vitest here rather than the lexical test utils, which I got wrong first time; and dropping the narrowing made the TableCellNode and RangeSelection type imports unused, so those are gone. 21 tests pass across the two files and tsc --noEmit is clean.

…es a lone shadow root, and deleting the last block keeps the root editable

## Description

Review follow-ups to the selection and caret boundary work on this branch.

`$normalizeSelectionForSelectAll` keeps the select-all points at the element
level when both ends resolve into the same top-level shadow root, so that
selection's anchor is the RootNode. `RangeSelection.insertParagraph()` opens
with a branch for an element point on a root or shadow root that only splices a
paragraph in, with no `isCollapsed()` guard, so Enter over that selection left
the widget in place and merely prepended an empty paragraph — worse than before
the branch existed, where the selection at least normalized into the widget and
replaced its text. `insertNodes()` has the same branch but calls `removeText()`
up front, which is why paste and typing were already correct. `insertParagraph()`
now does the same, so Enter over a select-all yields two empty paragraphs, which
is what Enter over a select-all of ordinary paragraphs produces.

Removing the last top-level node left the RootNode with no children and nowhere
to put a caret. `$removeTextFromCaretRange` had gained a repair for the
select-all case; the rule now lives in one place, the new
`$restoreEmptyRootParagraph` in `LexicalUtils.ts`, and `deleteCharacter` calls
it after removing an adjacent node beside a block cursor. That covers the
pre-existing block-`DecoratorNode` branch too, which had the same gap.

Also in this change:

- `RangeSelection.removeText()` reimplemented
  `$internalRefreshSelectionFormatAndStyle` inline; it now calls the helper.
- `$splitNodeAtPoint`'s `stopAtUnsplittableInline` flag never tested
  `isInline()` — it stops on any unsplittable `ElementNode`, which is only ever
  an inline one because `$removeTextAndSplitBlock`'s walk stops before it
  reaches a block. Renamed to `stopAtUnsplittableNode`, and the docs now say
  where the inline guarantee actually comes from.
- `$handleBeforeInput` prevents the default for `historyUndo`/`historyRedo`
  whether or not anything handles the command, so with no history extension
  registered undo is a no-op rather than native undo. That matches what the
  same inputType already does on the RangeSelection path; the comment now
  says so.

## Test plan

### Before

Source changes reverted, the three new tests kept:

```
$ npx vitest run --project unit packages/lexical/src packages/lexical-playground

 FAIL  |unit| packages/lexical-playground/__tests__/unit/Issue6938Repro.test.ts > Select-all + delete over a columns layout (meta#6938) > replaces the widget when Enter is pressed over a select-all
AssertionError: expected 'paragraph()|layout-container(layout-i…' to be 'paragraph()|paragraph()' // Object.is equality
Expected: "paragraph()|paragraph()"
Received: "paragraph()|layout-container(layout-item(paragraph(text[col1])),layout-item(paragraph(text[col2])))"

 FAIL  |unit| packages/lexical/src/__tests__/unit/Issue8939Repro.test.ts > block cursor deletion beside an ElementNode (meta#8939) > deleting the only 'decorator' leaves the root editable
 FAIL  |unit| packages/lexical/src/__tests__/unit/Issue8939Repro.test.ts > block cursor deletion beside an ElementNode (meta#8939) > deleting the only 'shadowRoot' leaves the root editable
AssertionError: expected [] to have a length of 1 but got +0

 Test Files  2 failed | 93 passed (95)
      Tests  3 failed | 1677 passed (1680)
```

### After

```
$ npx vitest run --project unit

 Test Files  285 passed (285)
      Tests  4591 passed | 1 skipped (4592)

$ pnpm run ci-check
(tsc, tsc-scripts, tsc-extension, tsc-website, flow, prettier, lint — exit 0)
```

The e2e suite was not run in this environment. The specs this branch touches
(`Links`, `ClearFormatting`, `Indentation`, `KeyboardShortcuts`) are unchanged
by this commit and run in CI's e2e job.
…and the caret inside it

## Description

Three review follow-ups to the previous commit, which restored a paragraph
into an emptied RootNode but stopped short in two ways.

The restored paragraph was not selected. After Backspace over a lone block
decorator the state was `root[paragraph[]]` with the anchor still at
`(element, root, 0)`, before the new paragraph rather than in it, so the next
Enter spliced its paragraph *above* and left the caret in the first one — the
opposite of Enter in an ordinary empty document. `deleteCharacter` now selects
the paragraph it restored.

The repair covered only the document root, but the same removal one level down
leaves a shadow root childless: `root[shadowRoot[blockDecorator]]` plus
Backspace at the block cursor gave `root[shadowRoot[]]` with the caret on the
shadow root, which for a table cell or a CollapsibleContentNode is exactly the
"nowhere to put a caret" failure the repair exists to prevent.
`$restoreEmptyRootParagraph` is therefore now `$restoreEmptyContainerParagraph`,
taking the container to repair; `deleteCharacter` passes the parent of the node
it removed, and `$removeTextFromCaretRange` passes the nearest root or shadow
root the range was inside, falling back to the root for a range that covered
that container too.

That also settles the third case: Enter over a selection covering all of a
shadow root's content produced one empty paragraph when the selection was
described with element points (the shape `$selectAll` produces for a top-level
shadow root) and two when it was described with text points, because only the
root was refilled before `insertParagraph`'s splice branch ran. Both shapes now
produce two, and the previous commit's rationale for the root case holds here
as well.

A ParagraphNode is not a valid child of every shadow root — a TableNode holds
rows, a TableRowNode holds cells — so the helper documents that its caller must
pass a block container. Each caller has just removed a block from it, which is
what establishes that; neither a TableRowNode nor a TableCellNode is ever
removed by these branches (`$needsBlockCursorBeside` is false for both).

## Test plan

### Before

Source changes reverted, the new assertions kept:

```
$ npx vitest run --project unit packages/lexical/src/__tests__/unit/Issue8939Repro.test.ts

 FAIL  Issue8939Repro.test.ts > deleting the only 'decorator' leaves the root editable
AssertionError: expected 'root' to be '30' // Object.is equality
 FAIL  Issue8939Repro.test.ts > deleting the only 'shadowRoot' leaves the root editable
AssertionError: expected 'root' to be '35' // Object.is equality
 FAIL  Issue8939Repro.test.ts > deleting the only block inside a shadow root keeps it editable
AssertionError: expected +0 to be 1 // Object.is equality
 FAIL  Issue8939Repro.test.ts > Enter over all of a shadow root splits an empty paragraph ('element' points)
AssertionError: expected [ [ 'paragraph', true ] ] to deeply equal [ [ 'paragraph', true ], …(1) ]

 Test Files  1 failed (1)
      Tests  4 failed | 8 passed (12)
```

### After

```
$ npx vitest run --project unit

 Test Files  285 passed (285)
      Tests  4594 passed | 1 skipped (4595)

$ pnpm run ci-check
(tsc, tsc-scripts, tsc-extension, tsc-website, flow, prettier, lint — exit 0)
```

The e2e suite was not run in this environment; this commit touches no spec
files.
…pe in the tests this branch adds

## Description

The tests added on this branch narrow a node with a type guard and then use
it, spelled three different ways: `assert($isX(node), 'Expected X')`,
`if (!$isX(node)) { throw new Error('Expected an X') }`, and a `!` non-null
assertion on `getChildAtIndex`. `$assertNodeType` from
`lexical/src/__tests__/utils` already does exactly this in one expression,
returns the narrowed node, and reports the type it actually got, so the
hand-written guards are replaced with it:

- `packages/lexical/src/__tests__/unit/Issue8939Repro.test.ts`
- `packages/lexical/src/__tests__/unit/Issue6781Repro.test.ts`
- `packages/lexical/src/__tests__/unit/LexicalSelection.test.ts` (the
  `Regression tests for meta#8075` block)
- `packages/lexical-table/src/__tests__/unit/LexicalTableSelection.test.tsx`
  (the `regression meta#8075` block)
- `packages/lexical-playground/__tests__/unit/CardNode.test.ts` and
  `Issue6938Repro.test.ts`

Two guards got more specific on the way: the layout walk in `Issue6938Repro`
now asserts `$isLayoutContainerNode` / `$isLayoutItemNode` rather than
`$isElementNode`, and the shadow-root reads in `Issue8939Repro` assert
`$isTestShadowRootNode`.

`assert($isRangeSelection(...))` is left alone — a selection is not a node, so
`$assertNodeType` does not apply. Only the assertions this branch introduced
are touched; the identical pattern elsewhere in these files predates it.

## Test plan

Test-only refactor with no behavior change: the same 4594 unit tests pass, and
each converted assertion is the same predicate over the same node.

### After

```
$ npx vitest run --project unit

 Test Files  285 passed (285)
      Tests  4594 passed | 1 skipped (4595)

$ pnpm run ci-check
(tsc, tsc-scripts, tsc-extension, tsc-website, flow, prettier, lint — exit 0)
```
@etrepum
etrepum added this pull request to the merge queue Aug 30, 2026
@etrepum
etrepum removed this pull request from the merge queue due to a manual request Aug 30, 2026
…nd keep select-all scoped inside a shadow root

## Description

Three defects found reviewing this branch, two of them in changes it made.

**A format armed on a collapsed caret was cancelled by the next edit.** The
meta#8817 change called `$internalRefreshSelectionFormatAndStyle` from
`ElementNode.select()` and `TextNode.select()`, so any caret move to a
different node re-derived format and style from the node it landed on. But
`select()` is not only navigation — it is how nearly every edit repositions its
own caret. Cmd+B then Enter at the end of a heading or list item put the caret
in the block `insertNewAfter()` had just created, whose `__textFormat` is 0,
and the next character came out unbolded; the same for a paragraph split (the
trailing TextNode carries its own format), for Shift+Enter, and for paste.

Sweeping seventeen operations with a format armed, against `main`, shows the
shape of the problem: patching `insertParagraph` and `insertLineBreak` to
re-arm what they had pending fixed seven of them and left paste still broken,
with no way to know which caller is next. `select()` cannot tell an edit
repositioning its own caret from a user navigating away, so the refresh is
removed from both `select()` methods and meta#8817 is dropped from this branch —
its `Issue8817Repro.test.ts` asserted exactly the removed behavior and goes
with it. `removeText` keeps its own call (meta#6781): that is one operation with a
defined caret landing, not a shared primitive, and its tests still pass.

**A select-all scoped inside a shadow root escalated to its parent.**
`$normalizeSelectionForSelectAll` kept element-level points whenever both ends
resolved into the same top-level shadow root, which is also true of a select-all
*within* one. Inside a table that left the cell's own children in the range, so
the next select-all widened to the row and then the table, and a delete removed
the rows and cells rather than their text. It now keeps element points only when
the points were set on the RootNode — the meta#6938 case, which is what
`$selectAll()` with no argument and the `SELECT_ALL_COMMAND` handler both
produce. A scoped select-all normalizes as it did before, so repeated Ctrl+A
inside a cell stays in the cell.

**`$restoreEmptyContainerParagraph` could put a paragraph in a `<table>`.** It
took the caller's word that the container held blocks; `$removeTextFromCaretRange`
derives that container from the range anchor and cannot promise it. The
obligation is now mechanical: for anything but the RootNode, a paragraph is
restored only where a block was removed (`INTERNAL_$isBlock`), which admits a
table cell and rejects a TableNode holding rows or a TableRowNode holding cells.

## Test plan

New `ArmedFormatSurvivesEdits.test.ts` covers Enter in five block types,
Shift+Enter, both paste shapes, and the text typed after Enter;
`LexicalTableSelection.test.tsx` gains the repeated-select-all case (run inside
one update, since a DOM round-trip renormalizes the points and hides it).

### Before

Source changes reverted, the new tests kept:

```
$ npx vitest run --project unit packages/lexical/src/__tests__/unit/ArmedFormatSurvivesEdits.test.ts packages/lexical-table/src/__tests__/unit/LexicalTableSelection.test.tsx

 FAIL  ArmedFormatSurvivesEdits.test.ts > Enter in 'a heading'
 FAIL  ArmedFormatSurvivesEdits.test.ts > Enter in 'a list item'
 FAIL  ArmedFormatSurvivesEdits.test.ts > Enter in 'the middle of a paragraph'
AssertionError: expected +0 to be 1 // Object.is equality
 FAIL  ArmedFormatSurvivesEdits.test.ts > Shift+Enter
AssertionError: expected +0 to be 1 // Object.is equality
 FAIL  ArmedFormatSurvivesEdits.test.ts > pasting inline content
AssertionError: expected +0 to be 1 // Object.is equality
 FAIL  ArmedFormatSurvivesEdits.test.ts > pasting a block
AssertionError: expected +0 to be 1 // Object.is equality
 FAIL  LexicalTableSelection.test.tsx > repeated select-all inside a table cell > stays scoped to the cell and leaves the table intact
AssertionError: expected 'element' to be 'text' // Object.is equality

 Test Files  2 failed (2)
      Tests  7 failed | 20 passed (27)
```

### After

```
$ npx vitest run --project unit

 Test Files  285 passed (285)
      Tests  4598 passed | 1 skipped (4599)

$ pnpm run ci-check
(tsc, tsc-scripts, tsc-extension, tsc-website, flow, prettier, lint — exit 0)
```

The e2e suite was not run in this environment; this commit touches no spec
files.

This branch was successfully deployed

2 active deployments
Preview – lexical — 7f053333 Deployed Aug 30, 2026 by vercel[bot]
Preview – lexical-playground — 7f053333 Deployed Aug 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants