lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: New table selection breaks when table cells are already selected

Open PeterBul opened this issue 1 year ago • 0 comments

Trying to select table cells when cells are already selected leads to a range selection instead of a grid selection. In Chrome, this leads to a range selection that has the correct anchor and focus nodes. In Firefox the range selection is completely wrong, with the focus node being the anchor node and the selection going in the wrong direction.

Lexical version: 0.11.1

Steps To Reproduce

  1. Add table with 4 rows and 4 columns
  2. Select the 4 center cells.
  3. Try to select the 2 cells to the right in the group of already selected cells (col 2, row 1-2 (0 indexed))
  4. This should result in a range selection going through the cells in Chrome and a different kind of edge selection in Firefox. The visual selection in Firefox does not match the underlying selection held by Lexical. (This can be inspected with the debugger in Lexical Playground), Lexical has the selection (col 2-3, row 2) while the visual selection is (col 2, row 1-2).

https://github.com/facebook/lexical/assets/23295934/68a8f9d8-cc44-4d6a-b2e9-800066a45b2b

Here, the cells marked with blue are the ones that are actually selected in Lexical table-selection-firefox

https://github.com/facebook/lexical/assets/23295934/d55e26a1-bbcb-4fc3-8d5d-9b87beb4805b

Link to code example: https://codesandbox.io/s/lexical-table-plugin-example-with-experimental-forked-trcmsx

The current behavior

Selecting cells in a table with cells already selected results in a range selection. This selection has the right anchor and focus nodes in Chrome but not in Firefox.

The expected behavior

Selecting cells in a table with cells already selected should result in a new grid selection.

PeterBul avatar Jun 23 '23 13:06 PeterBul