lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Shift+down selects an extra subsequent element

Open serey-roth opened this issue 1 year ago • 3 comments

https://www.loom.com/share/78508267145b422081498fe08c461626?sid=13463229-4383-4ec6-80d2-741805a691c7

Lexical version: 0.17

Steps To Reproduce

  1. Insert a paragraph with some text.
  2. Insert a 2x2 table.
  3. Delete the preceding paragraph.
  4. Insert a paragraph after the table, with some text.
  5. 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 focusNode being the last cell. However, when the selectionchange event fires, the DOM selection now includes the next element after the table.

serey-roth avatar Aug 19 '24 18:08 serey-roth

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.

ivailop7 avatar Aug 27 '24 13:08 ivailop7

Would be nice to get @etrepum 's view on this one as well, to me it seems like a quite significant selection issue.

ivailop7 avatar Aug 28 '24 16:08 ivailop7

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.

etrepum avatar Aug 28 '24 19:08 etrepum