Repository navigation
[lexical-utils] Bug Fix: notify when selection overlay rectangles are removed - #9117
Conversation
… 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @mehuljariwala! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Description
positionNodeOnRangeremoves surplus overlay elements when a range produces fewer rectangles, but does not callonRepositionif 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:
After
ESLint and Prettier passed for both changed files.
tsc --noEmitpassed. Browser/E2E tests were not run; the change concerns callback delivery after existing rectangle removal. Prepared with AI assistance.