lexical
lexical copied to clipboard
Bug: Shift+down selects an extra subsequent element
https://www.loom.com/share/78508267145b422081498fe08c461626?sid=13463229-4383-4ec6-80d2-741805a691c7
Lexical version: 0.17
Steps To Reproduce
- Insert a paragraph with some text.
- Insert a 2x2 table.
- Delete the preceding paragraph.
- Insert a paragraph after the table, with some text.
- Press "Shift+Down arrow" at the end of the first paragraph.
The current behavior
Both the table and the second paragraph are selected.
The expected behavior
Only the table should be selected.
Impact of fix
- The bug doesn't happen with just a subsequent paragraph. If there is an image or a second table, they will be included in the new selection too. This could mess up deletion if we're trying to delete just the table.
- The DOM selection is applied correctly when "shift+down"-ing into a table, with the next
focusNodebeing the last cell. However, when theselectionchangeevent fires, the DOM selection now includes the next element after the table.
I CAN reproduce this issue with a Table, Page Break, Divider, Collapsible Section, I CANNOT reproduce with Excalidraw, Poll, Image. It's not tables specific, so I can confirm it's not TableSelection specific, it's much lower down the selection stack.
Would be nice to get @etrepum 's view on this one as well, to me it seems like a quite significant selection issue.
Tbh I think selection has a lot of broken edge cases when it's not a RangeSelection of text. Haven't recently taken a close look at any of them.