From 51e55994bb21258241e069aa883c099ff60c6a72 Mon Sep 17 00:00:00 2001 From: sahejkm Date: Sun, 9 Jun 2024 13:38:58 +0800 Subject: [PATCH 1/2] Follow up on #6267 handle multi column delete crash on forward selection at end of the table --- .../__tests__/e2e/Tables.spec.mjs | 49 +++++++++++++++++++ .../lexical-table/src/LexicalTableUtils.ts | 5 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs b/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs index 45da439a5..cf10ba377 100644 --- a/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs +++ b/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs @@ -2620,6 +2620,55 @@ test.describe.parallel('Tables', () => { ); }); + test('Delete columns forward at end of table', async ({ + page, + isPlainText, + isCollab, + }) => { + await initialize({isCollab, page}); + test.skip(isPlainText); + if (IS_COLLAB) { + // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) + page.setViewportSize({height: 1000, width: 3000}); + } + + await focusEditor(page); + + await insertTable(page, 2, 4); + + await selectCellsFromTableCords( + page, + {x: 1, y: 1}, + {x: 3, y: 1}, + false, + false, + ); + + await deleteTableColumns(page); + + await assertHTML( + page, + html` +


+ + + + + + + +
+


+
+


+
+


+ `, + ); + }); + test('Deselect when click outside #3785 #4138', async ({ page, isPlainText, diff --git a/packages/lexical-table/src/LexicalTableUtils.ts b/packages/lexical-table/src/LexicalTableUtils.ts index 5c5bf3e36..572b59647 100644 --- a/packages/lexical-table/src/LexicalTableUtils.ts +++ b/packages/lexical-table/src/LexicalTableUtils.ts @@ -636,7 +636,10 @@ export function $deleteTableColumn__EXPERIMENTAL(): void { const {cell} = nextColumn; $moveSelectionToCell(cell); } else { - const previousRow = focusRowMap[focusStartColumn - 1]; + const previousRow = + focusStartColumn < anchorStartColumn + ? focusRowMap[focusStartColumn - 1] + : focusRowMap[anchorStartColumn - 1]; const {cell} = previousRow; $moveSelectionToCell(cell); } From cd7405f5f496d55e312c3cf190c7589845c63bcd Mon Sep 17 00:00:00 2001 From: "local-dev-korbit-ai-mentor[bot]" <130798245+local-dev-korbit-ai-mentor[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:16:55 +0000 Subject: [PATCH 2/2] [skip ci]