Skip to content

[lexical] Bug Fix: preserve inline decorators across soft-wrap line deletion - #63

Closed
etrepum wants to merge 5 commits into
mainfrom
fix/9234-soft-wrap-line-deletion
Closed

etrepum wants to merge 5 commits into
mainfrom
fix/9234-soft-wrap-line-deletion

Conversation

@etrepum

@etrepum etrepum commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Description

Deleting to a visual line boundary also removes adjacent inline decorators from the neighbouring wrapped line. After measuring the boundary with a collapsed native caret, Lexical extends the model selection over every adjacent inline decorator without consulting layout.

Remove that post-measurement traversal from the deletion path. Keep the decorator pre-pass and the normalization of native endpoints inside a decorator's private text. Forward and backward line deletion now preserve the decorator across the reported soft wrap, while the same-line and hard-break cases continue to pass.

Add browser regressions for rich/plain text, forward/backward deletion, spacing variants, empty/text/button decorators, and text-bearing decorators straddling a wrap. Expand the same-line controls to include consecutive decorators and raised alignment.

The removed correction was introduced for Selection.modify('extend') in meta#7270. The deletion path later switched to a collapsed native modify('move') in meta#8774, and meta#9247 normalized move endpoints inside decorator text. A Chromium probe confirms the relevant distinction: extend stops before a trailing image while move lands after it. The general RangeSelection.modify path retains its decorator correction.

Extend the browser coverage to include inline and inline-block image wrappers and repeated deletion across image/paragraph boundaries from meta#7270. These command-based tests run on Linux as well as other platforms; the original keyboard E2E cases are macOS-only.

Run canary E2E alongside the core tests without a repository-owner condition. This enables the existing Ubuntu/Node 24/Chromium/rich-text canary workflow in forks too.

Closes meta#9234

Test plan

Local browser runs used an uncommitted vitest.9234.config.mts that imports the normal Vitest configuration and overrides only Chromium's executable path. Chromium 153.0.8010.12 was downloaded directly from Google after Playwright's CDN archive failed; Firefox and WebKit use the pinned Playwright 1.63.0 builds. All three engines ran on Linux.

Before

New tests against unchanged main (1e803309):

VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts InlineDecoratorLineDeletion.test.ts
 Test Files  3 failed (3)
      Tests  120 failed | 144 passed (264)

After

Full browser suite after the fix, before adding the historical image/repeated-deletion coverage:

VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts --no-file-parallelism
 Test Files  113 passed | 1 skipped (114)
      Tests  1115 passed | 7 skipped (1122)

The expanded focused suite, including the historical image/repeated-deletion coverage:

VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts InlineDecoratorLineDeletion.test.ts --no-file-parallelism
 Test Files  3 passed (3)
      Tests  420 passed (420)

pnpm run tsc-test, ESLint and Prettier for the changed files, and git diff --check also passed.

Further exploration found a separate native-measurement limitation with consecutive empty decorators straddling a wrap: Firefox/WebKit can stop short of the visual boundary. Those cases also fail on unchanged main and remain unresolved here. Same-line consecutive empty decorators are covered and pass.

…eletion

## Description

Deleting to a visual line boundary also removes adjacent inline decorators from the neighbouring wrapped line. After measuring the boundary with a collapsed native caret, Lexical extends the model selection over every adjacent inline decorator without consulting layout.

Remove that post-measurement traversal from the deletion path. Keep the decorator pre-pass and the normalization of native endpoints inside a decorator's private text. Forward and backward line deletion now preserve the decorator across the reported soft wrap, while the same-line and hard-break cases continue to pass.

Add browser regressions for rich/plain text, forward/backward deletion, spacing variants, empty/text/button decorators, and text-bearing decorators straddling a wrap. Expand the same-line controls to include consecutive decorators and raised alignment.

Closes meta#9234

## Test plan

Local browser runs used an uncommitted `vitest.9234.config.mts` that imports the normal Vitest configuration and overrides only Chromium's executable path. Chromium 153.0.8010.12 was downloaded directly from Google after Playwright's CDN archive failed; Firefox and WebKit use the pinned Playwright 1.63.0 builds. All three engines ran on Linux.

### Before

New tests against unchanged main (`1e803309`):

```sh
VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts InlineDecoratorLineDeletion.test.ts
```

```text
 Test Files  3 failed (3)
      Tests  120 failed | 144 passed (264)
```

### After

```sh
VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts --no-file-parallelism
```

```text
 Test Files  113 passed | 1 skipped (114)
      Tests  1115 passed | 7 skipped (1122)
```

`pnpm run tsc-test`, ESLint and Prettier for the changed files, and `git diff --check` also passed.

Further exploration found a separate native-measurement limitation with consecutive empty decorators straddling a wrap: Firefox/WebKit can stop short of the visual boundary. Those cases also fail on unchanged main and remain unresolved here. Same-line consecutive empty decorators are covered and pass.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Deploying lexical with  Cloudflare Pages  Cloudflare Pages

Latest commit: c376388
Status:⚡️  Build in progress...

View logs

## Description

The canary E2E job is skipped in this fork because it only allows the facebook owner. Also allow etrepum/lexical so the existing Ubuntu/Node 24/Chromium/rich-text canary runs on this PR and on future fork PRs after the change reaches main.

## Test plan

### Before

GitHub Actions run 37142184364:

```text
e2e-tests: completed / skipped
```

### After

```text
Checking formatting...
All matched files use Prettier code style!
```

`git diff --check` passed. The canary run will be verified after publishing this commit.
## Description

Remove the repository condition from the canary E2E job. Run it alongside core tests for every repository using this workflow, including forks.

## Test plan

### Before

```text
if: github.repository_owner == 'facebook' || github.repository == 'etrepum/lexical'
```

### After

The job has no repository condition. Prettier validation passed:

```text
Checking formatting...
All matched files use Prettier code style!
```

GitHub Actions will validate the canary run after publishing.
## Description

The decorator traversal removed for meta#9234 originated in meta#7270, which also fixed repeated forward deletion and deletion at image boundaries. Cover those cases directly with browser tests to guard against restoring the original regression.

Exercise inline and inline-block image wrappers, private text, consecutive decorators, raised alignment, and repeated deletion across paragraph boundaries in rich and plain text.

## Test plan

### Before

The existing full browser suite passed: 113 passed and 1 skipped files; 1115 passed and 7 skipped tests. The image and repeated-deletion cases added here were not covered by that focused browser fixture.

### After

VITEST_BROWSER=chromium,firefox,webkit pnpm test-browser --config vitest.9234.config.mts InlineDecoratorLineDeletion.test.ts --no-file-parallelism

3 test files passed; 420 tests passed across Chromium, Firefox, and WebKit on Linux. The local config only overrides Chromium's executable path.

pnpm run tsc-test, ESLint and Prettier for the changed test, and git diff --check passed.
## Description

Remove the comment left in place of the deleted decorator traversal. The rationale for the change is documented in the PR.

## Test plan

### After

Comment-only change.

```text
$ pnpm exec prettier --check packages/lexical/src/LexicalSelection.ts
Checking formatting...
All matched files use Prettier code style!
```

`git diff --check` passed with no output.
@etrepum etrepum closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [lexical] Line deletion at a soft wrap also removes an inline decorator from the neighbouring visual line

1 participant