Skip to content

[lexical-table] Bug Fix: Prevent nested table paste when hasNestedTables is false and merge fails#8440

Draft
matingathani wants to merge 4 commits into
facebook:mainfrom
matingathani:fix/table-nested-paste
Draft

[lexical-table] Bug Fix: Prevent nested table paste when hasNestedTables is false and merge fails#8440
matingathani wants to merge 4 commits into
facebook:mainfrom
matingathani:fix/table-nested-paste

Conversation

@matingathani
Copy link
Copy Markdown

Description

When pasting a single table into a multi-cell table selection, if $insertTableIntoGrid fails to merge the pasted table into the destination grid, the command handler would return false, allowing $insertGeneratedNodes to fall back to standard insertion which created a nested table even when hasNestedTables: false.

This PR ensures the paste is always handled (rejected with silent no-op) when the table merge fails and nested tables are not enabled.

Closes #8077

Test plan

Before

Pasting a table into a multi-cell selection could create a nested table when hasNestedTables was false.

After

Pasting a table into a multi-cell selection is always rejected when hasNestedTables is false. The merge is attempted, and if it fails the paste is silently dropped rather than creating a nested table.

Copilot AI review requested due to automatic review settings May 1, 2026 03:42
@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 2, 2026 10:55pm
lexical-playground Ready Ready Preview, Comment May 2, 2026 10:55pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread packages/lexical-table/src/LexicalTableCellNode.ts
@matingathani matingathani force-pushed the fix/table-nested-paste branch from 8a89439 to 60c234d Compare May 2, 2026 00:46
@matingathani
Copy link
Copy Markdown
Author

@etrepum Branch has been rebased on main. All tests pass (the one added test covers the regression: pasting a single table into a multi-cell selection when hasNestedTables: false should always reject the paste rather than falling back to nested insertion).

If you had specific feedback in mind from your earlier review, I'm happy to address it. Let me know if there are edge cases you'd like covered or changes needed.

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes without your change, so either your change doesn't fix anything or the test isn't written correctly.

@etrepum etrepum marked this pull request as draft May 5, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Paste tables in tables even if hasNestedTables: false

3 participants