Skip to content

[lexical-table][lexical-playground] Chore: Deprecate getShape() and migrate playground - #8853

Merged
etrepum merged 6 commits into
meta:mainfrom
mayrang:fix/table-getshape-merged-cells
Jul 18, 2026
Merged

etrepum merged 6 commits into
meta:mainfrom
mayrang:fix/table-getshape-merged-cells

Conversation

@mayrang

@mayrang mayrang commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TableSelection.getShape() only considers the colSpan/rowSpan of the anchor and focus cells, producing incorrect results when a third merged cell spans beyond the initial boundary. Rather than fix the implementation and risk breaking consumers that depend on the current behavior, this PR marks getShape() as @deprecated and migrates the only internal caller — computeSelectionCount in TableActionMenuPlugin — to use $computeTableMap + $computeTableCellRectBoundary directly (renamed to $computeSelectionCounts).

$computeTableCellRectBoundary and its return type TableCellRectBoundary are now exported from @lexical/table.

Test plan

  • pnpm test-unit --project unit -- LexicalTableSelection — 14 passed
    • getShape baseline: non-merged 2×2 table returns correct shape
  • Manual playground: create 3×3 table → merge row 1 cols 1-2 → select cells → context menu shows correct row/column count
  • tsc / flow / prettier / eslint clean

@vercel

vercel Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Jul 17, 2026 6:39pm
lexical-playground Ready Ready Preview Jul 17, 2026 6:39pm

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 Jul 17, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Jul 17, 2026
selection.insertNodes(nodes);
}

// TODO Deprecate this method. It's confusing when used with colspan|rowspan

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better to deprecate this method? It's only used once and computeSelectionCount can inline the correct version of this (and get renamed accordingly).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I originally had this as a deprecation with the logic inlined into computeSelectionCount, but went conservative and just fixed the implementation. Should I switch the PR to deprecation + inline instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think so, reducing the API surface here (eventually) makes sense

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done — getShape() is marked @deprecated, computeSelectionCount is renamed to $computeSelectionCounts and uses $computeTableMap + $computeTableCellRectBoundary directly. Also exported $computeTableCellRectBoundary and its TableCellRectBoundary type from @lexical/table.

@mayrang mayrang changed the title [lexical-table] Bug Fix: Fix getShape() boundary expansion for merged cells [lexical-table][lexical-playground] Bug Fix: Fix and deprecate getShape() Jul 17, 2026
const stopY = Math.max(
anchorCellNodeRect.rowIndex + anchorCellNodeRect.rowSpan - 1,
focusCellNodeRect.rowIndex + focusCellNodeRect.rowSpan - 1,
const {anchorTable, anchorCell, focusCell} = $getCellNodes(this);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can discard the changes to getShape, no need to take on the risk of this breaking someone's expectations of the old behavior. If they want it to work correctly they can get off the deprecated path.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reverted — getShape() now keeps the original implementation with only the @deprecated annotation added.

@mayrang mayrang changed the title [lexical-table][lexical-playground] Bug Fix: Fix and deprecate getShape() [lexical-table][lexical-playground] Chore: Deprecate getShape() and migrate playground Jul 17, 2026
@etrepum
etrepum added this pull request to the merge queue Jul 18, 2026
Merged via the queue into meta:main with commit dd51d8d Jul 18, 2026
44 checks passed
@etrepum etrepum mentioned this pull request Jul 29, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 06265f4a Deployed Jul 17, 2026 by vercel[bot]
Preview – lexical-playground — 06265f4a Deployed Jul 17, 2026 by vercel[bot]
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.

2 participants