Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lexical][Tables] Follow up on #6267 handle multi column delete crash on forward selection at end of the table #23

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
<table class="PlaygroundEditorTheme__table">
<tr>
<th
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
</tr>
<tr>
<th
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
</tr>
</table>
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
});

test('Deselect when click outside #3785 #4138', async ({
page,
isPlainText,
Expand Down
5 changes: 4 additions & 1 deletion packages/lexical-table/src/LexicalTableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading