lexical
lexical copied to clipboard
[WIP][lexical-playground] Bug Fix: Layout deletion when it's the first node
Description
Current behavior:
- Currently, when a layout is the first node in the editor, selecting all content and deleting (either through keyboard or mouse selection) leads to an invalid state of the widget. This issue only occurs when the layout is the first node - if there's a paragraph before the layout, deletion works correctly.
Changes being added:
- Added
$handleLayoutDeletefunction in LayoutPlugin to properly handle layout deletion - Added command registrations for all delete operations (character, word, line)
- Added comprehensive e2e tests to verify deletion behavior in various scenarios
Closes #6938
Test plan
Before
https://github.com/user-attachments/assets/068a5e77-44e4-4f16-a587-fcd0b89fcfe2
After
The following test cases have been added to verify the fix:
- Layout deletion when it's the first node
- Layout deletion with surrounding content
- Testing different delete operations:
- Regular delete/backspace
- Word delete (Ctrl+Backspace)
- Line delete (Cmd+Backspace)
All tests pass and verify that:
- Layout deletion works correctly regardless of its position
- Selection and deletion work properly from both inside and outside the layout
- Editor maintains a valid state after deletion
https://github.com/user-attachments/assets/d0946815-3ada-4f33-bb77-942e780b1bb7
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 9, 2025 0:53am |
| lexical-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 9, 2025 0:53am |
I haven’t looked at this at all yet but usually this type of thing is handled with collapseAtStart rather than command listeners