Skip to content

[lexical] Bug Fix: resolve line deletion endpoints inside inline decorators - #9247

Merged
etrepum merged 1 commit into
meta:mainfrom
maximilliangrand:fix/inline-decorator-line-deletion
Sep 27, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
maximilliangrand:fix/inline-decorator-line-deletion

Conversation

@maximilliangrand

Copy link
Copy Markdown
Contributor

Description

Forward line deletion can remove only one character when the line ends in a text-bearing inline decorator. For example, with aaaa bbbb [X] on one line and the caret after aa, DELETE_LINE_COMMAND(false) leaves the decorator and most of the text behind.

Chromium's native lineboundary movement can land on the decorator's internal DOM Text node. That text is not a Lexical TextNode, so range resolution fails and deleteLine falls back to character deletion. Normalize this measurement endpoint to the inline decorator's wrapper edge before applying the range.

This is limited to line deletion and non-isolated inline decorators belonging to the same editor, with text inside the decorator wrapper's light DOM. Existing root/slot clamping remains in place, and measurement keeps the live DOM selection collapsed. No change to the general selection resolver.

Found while investigating #9234; the separate soft-wrap over-deletion reported there is not fixed by this PR.

Test plan

Before

On unchanged 02471a8f91fcb787256c6dc66f2e3ccad20e6eee, with the new test file:

VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser InlineDecoratorLineDeletion.test.ts
Test Files  1 failed | 2 passed (3)
     Tests  8 failed | 64 passed (72)

Failures are Chromium forward deletion with direct/nested decorator text, normal/raised alignment, and rich/plain-text extensions.

After

The same command:

Test Files  3 passed (3)
     Tests  72 passed (72)
  • Full three-engine browser suite: 761 passed | 7 skipped (768). After adding the light-DOM containment guard, the focused new/deletion/shadow-selection suites passed 220 tests with 2 skips.
  • pnpm test-unit: 8797 passed | 1 skipped | 2 failed. Both failures are source-link-label assertions in typedocExternalLinks.test.ts; running that file against unchanged upstream source reproduces both failures.
  • pnpm run tsc-test, ESLint and Prettier for changed files, and git diff --check passed.
  • Independent real-browser checks of these cases in shadow-root and iframe editor roots: 72 passed across the three engines.

Validated on macOS arm64 with Node 26.7.0 and the pinned pnpm 11.24.0. Developed and reviewed with Codex assistance.

…rators

## Description

Forward line deletion can remove only one character when the line ends in a text-bearing inline decorator. For example, with `aaaa bbbb [X]` on one line and the caret after `aa`, `DELETE_LINE_COMMAND(false)` leaves the decorator and most of the text behind.

Chromium's native `lineboundary` movement can land on the decorator's internal DOM Text node. That text is not a Lexical TextNode, so range resolution fails and `deleteLine` falls back to character deletion. Normalize this measurement endpoint to the inline decorator's wrapper edge before applying the range.

This is limited to line deletion and non-isolated inline decorators belonging to the same editor, with text inside the decorator wrapper's light DOM. Existing root/slot clamping remains in place, and measurement keeps the live DOM selection collapsed. No change to the general selection resolver.

Found while investigating meta#9234; the separate soft-wrap over-deletion reported there is not fixed by this PR.

## Test plan

### Before

On unchanged `02471a8f91fcb787256c6dc66f2e3ccad20e6eee`, with the new test file:

```sh
VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser InlineDecoratorLineDeletion.test.ts
```

```text
Test Files  1 failed | 2 passed (3)
     Tests  8 failed | 64 passed (72)
```

Failures are Chromium forward deletion with direct/nested decorator text, normal/raised alignment, and rich/plain-text extensions.

### After

The same command:

```text
Test Files  3 passed (3)
     Tests  72 passed (72)
```

- Full three-engine browser suite: `761 passed | 7 skipped (768)`. After adding the light-DOM containment guard, the focused new/deletion/shadow-selection suites passed `220` tests with `2` skips.
- `pnpm test-unit`: `8797 passed | 1 skipped | 2 failed`. Both failures are source-link-label assertions in `typedocExternalLinks.test.ts`; running that file against unchanged upstream source reproduces both failures.
- `pnpm run tsc-test`, ESLint and Prettier for changed files, and `git diff --check` passed.
- Independent real-browser checks of these cases in shadow-root and iframe editor roots: `72 passed` across the three engines.

Validated on macOS arm64 with Node 26.7.0 and the pinned pnpm 11.24.0. Developed and reviewed with Codex assistance.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 27, 2026
@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 27, 2026 6:18pm UTC
lexical-playground Ready Ready Preview Sep 27, 2026 6:18pm UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – lexical — 200b39be Deployed Sep 27, 2026 by vercel[bot]
Preview – lexical-playground — 200b39be Deployed Sep 27, 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.

2 participants