Skip to content

[Breaking Changes][lexical] Bug Fix: Address deleteLine regression in #7248 - #7270

Merged
ivailop7 merged 5 commits into
meta:mainfrom
etrepum:delete-line-forward-regression
Mar 2, 2025
Merged

ivailop7 merged 5 commits into
meta:mainfrom
etrepum:delete-line-forward-regression

Conversation

@etrepum

@etrepum etrepum commented Mar 1, 2025 •

Copy link
Copy Markdown
Collaborator

Breaking Changes

To handle platform differences and avoid piercing shadow roots, arrow key navigation for RangeSelection is now handled by lexical in more scenarios when crossing the boundaries of elements. This should only affect "exotic" custom element nodes such as TableNode. All code in @lexical/table has been updated accordingly, but if you have something like a custom table implementation then it may require additional updates (probably in the direction of removing workarounds rather than adding them).

Description

Address deleteLine regression in #7248. The selection movement code had some logic errors and adding carets to the mix (which validate text offsets) messed it up. This fixes the problem mostly by improving RangeSelection.modify.

It now:

  • Checks for decorators around the focus and manually implements the appropriate movement (a decorator counts as a character or word, and any span of inline decorators will be skipped over for a lineboundary)
  • If no adjacent sibling is found (decorator or otherwise) then it will check to see if we are at the boundary between blocks and if so navigate that manually
  • Modifies the DOM selection to match the RangeSelection (since we may have already extended or moved around decorators) before asking the native platform to modify the selection
  • For lineboundary it will continue to skip through inline decorators afterwards if present

After fixing these issues, some of the TableNode selection code had to change as well, since it was dependent on the browsers doing weird things across shadow roots and fixing things up afterwards. Once that was cleaned up it also fixed some Firefox and table wrapper discrepancies (resulting in fewer test workarounds and skips). Note that I focused the scope of this specifically on left/right arrow keys for tables, up/down navigation should work as it did before.

Closes #7267

Test plan

All existing e2e tests pass, plus additional test coverage for forward deletion which had no coverage previously.

@vercel

vercel Bot commented Mar 1, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2025 7:55pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2025 7:55pm

@facebook-github-bot facebook-github-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 Mar 1, 2025
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 1, 2025
@etrepum etrepum changed the title [lexical] Bug Fix: Address deleteLine regression in #7248 [Breaking Changes][lexical] Bug Fix: Address deleteLine regression in #7248 Mar 2, 2025
@etrepum
etrepum marked this pull request as ready for review March 2, 2025 20:19
@etrepum

etrepum commented Mar 2, 2025

Copy link
Copy Markdown
Collaborator Author

/cc @ivailop7

@ivailop7
ivailop7 added this pull request to the merge queue Mar 2, 2025
Merged via the queue into meta:main with commit 0b11ddd Mar 2, 2025
etrepum added a commit to etrepum/lexical that referenced this pull request Oct 3, 2026
## 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.

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 7e1aed5c Deployed Mar 2, 2025 by vercel[bot]
Preview – lexical — 7e1aed5c Deployed Mar 2, 2025 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.

Bug: Forward line deletion stops working after running once

3 participants