Skip to content

[lexical-utils] Bug Fix: notify when selection overlay rectangles are removed - #9117

Merged
etrepum merged 1 commit into
meta:mainfrom
mehuljariwala:fix/range-overlay-removal-callback
Sep 8, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
mehuljariwala:fix/range-overlay-removal-callback

Conversation

@mehuljariwala

@mehuljariwala mehuljariwala commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

positionNodeOnRange removes surplus overlay elements when a range produces fewer rectangles, but does not call onReposition if the surviving rectangles keep their geometry. Consumers therefore miss the update when the overlay shrinks or disappears.

Mark removal as a reposition so the callback receives the updated elements. Add regression cases for two rectangles shrinking to one or zero. The tests use controlled rectangles to exercise callback bookkeeping, without relying on jsdom layout.

Test plan

Before

With the regression tests added and the production fix removed:

vitest run --project unit positionNodeOnRange
AssertionError: expected "vi.fn()" to be called 2 times, but got 1 times
Test Files  1 failed (1)
     Tests  2 failed | 2 passed (4)

After

vitest run --project unit packages/lexical-utils/src/__tests__/unit
Test Files  16 passed (16)
     Tests  232 passed (232)

ESLint and Prettier passed for both changed files. tsc --noEmit passed. Browser/E2E tests were not run; the change concerns callback delivery after existing rectangle removal. Prepared with AI assistance.

… removed

## Description

`positionNodeOnRange` removes surplus overlay elements when a range produces fewer rectangles, but does not call `onReposition` if the surviving rectangles keep their geometry. Consumers therefore miss the update when the overlay shrinks or disappears.

Mark removal as a reposition so the callback receives the updated elements. Add regression cases for two rectangles shrinking to one or zero. The tests use controlled rectangles to exercise callback bookkeeping, without relying on jsdom layout.

## Test plan

### Before

With the regression tests added and the production fix removed:

```text
vitest run --project unit positionNodeOnRange
AssertionError: expected "vi.fn()" to be called 2 times, but got 1 times
Test Files  1 failed (1)
     Tests  2 failed | 2 passed (4)
```

### After

```text
vitest run --project unit packages/lexical-utils/src/__tests__/unit
Test Files  16 passed (16)
     Tests  232 passed (232)
```

ESLint and Prettier passed for both changed files. `tsc --noEmit` passed. Browser/E2E tests were not run; the change concerns callback delivery after existing rectangle removal. Prepared with AI assistance.
@vercel

vercel Bot commented Sep 5, 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 5, 2026 8:31am UTC
lexical-playground Ready Ready Preview Sep 5, 2026 8:31am UTC

Request Review

@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Hi @mehuljariwala!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@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 5, 2026
@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Sep 8, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 8, 2026
Merged via the queue into meta:main with commit 9a23be2 Sep 8, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 17, 2026

This branch was successfully deployed

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