Skip to content

Commit

Permalink
[lexical-table] Bug Fix: cannot delete content when a table inside se…
Browse files Browse the repository at this point in the history
…lection (#6412)

Co-authored-by: Ivaylo Pavlov <ivailo90@gmail.com>
  • Loading branch information
placeba and ivailop7 authored Jul 28, 2024
1 parent 36fe1fd commit 01d7d0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
24 changes: 24 additions & 0 deletions packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,30 @@ test.describe.parallel('Tables', () => {
);
});

test('Can delete all with node selection', async ({
page,
isCollab,
isPlainText,
}) => {
await initialize({isCollab, page});
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('Text before');
await page.keyboard.press('Enter');
await insertSampleImage(page);
await page.keyboard.press('Enter');
await page.keyboard.type('Text after');
await insertTable(page, 2, 3);
await selectAll(page);
await page.keyboard.press('Backspace');
await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
});

test(`Horizontal rule inside cell`, async ({page, isPlainText, isCollab}) => {
await initialize({isCollab, page});
test.skip(isPlainText);
Expand Down
8 changes: 1 addition & 7 deletions packages/lexical-table/src/LexicalTableSelectionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,10 @@ export function applyTableHandlers(
if (!parentNode) {
return false;
}
const nextNode = table.getNextSibling() || table.getPreviousSibling();
table.remove();
if (nextNode) {
nextNode.selectStart();
} else {
parentNode.selectStart();
}
}
}
return true;
return false;
}

if ($isTableSelection(selection)) {
Expand Down

0 comments on commit 01d7d0a

Please sign in to comment.