← Back to Pull requests

[lexical-table] Bug Fix: Deleting a row no longer drops a merged cell changed earlier in the same update #9851

Closed
unknown closed this pull request without merging on Nov 12, 2026 09:43 UTC
View on GitHub
unknown unknown commented on Nov 08, 2026 17:18 UTC
Author

Description

$deleteTableRowAtSelection trims the row span of a merged cell that reaches past the deleted rows, and moves the cell into the next row when the deleted rows include its first row. It read cell.__rowSpan again after cell.setRowSpan(...), and a cell spanning several deleted rows was visited once per row.

When the cell is not yet writable in the update, setRowSpan clones it, so cell keeps the old span and this works. When the cell is already writable (for example $mergeCells and $deleteTableRowAtSelection called in one editor.update), setRowSpan changes it in place:

  • Deleting the first row of a 2-row merged cell skips the move, so the merged cell and its text are removed with the row. With TableExtension, the row is padded with empty cells.

  • Deleting two middle rows of a 4-row merged cell trims the span twice (4 -> 2 -> 1), leaving the row below one cell short.
  • Each cell is now handled once, from the span it had before the delete. Deleting rows in their own update, as the table menu does, already worked and is unchanged. $deleteTableColumnAtSelection reads the span before changing it and does not have this problem.

    Changeset

    .changeset/table-delete-row-merged-cell-same-update.md (@lexical/table patch, [fix] with a Verify: paragraph).

    Test plan

    New DeleteRowMergedCellSameUpdate.test.ts runs three cases (2-row merge, 2x2 merge, 4-row merge with two rows deleted) with the merge and the delete in separate updates and in the same update.

    pnpm exec vitest run --project unit packages/lexical-table/src/__tests__/unit/DeleteRowMergedCellSameUpdate.test.ts

    Before

         × deleting the top row of a 2-row merged …, in the same update as the merge
         × deleting the top row of a 2x2 merged ce…, in the same update as the merge
         × deleting two middle rows of a 4-row mer…, in the same update as the merge
          Tests  3 failed | 3 passed (6)
    
    - Expected
    + Received
      [
    -   "A2 | B1 B2",
    +   "A2",
      ]
    
      [
    -   "A2 | B1 C1 B2 C2 cs2",
    +   "A2 |  | ",
        "A3 | B3 | C3",
      ]
    
      [
    -   "A1 | B1 B2 B3 B4 rs2",
    -   "A4",
    +   "A1 | B1 B2 B3 B4",
    +   "A4 | ",
      ]
    

    After

          Tests  6 passed (6)
    

    pnpm exec vitest run --project unit packages/lexical-table: 38 files passed, 395 passed | 9 expected fail. pnpm run tsc, ESLint and Prettier on the changed files, and pnpm run check-changesets pass. Flow, browser and e2e tests were not run; the change has no API or DOM impact.

    Diff: 310 lines (+232 / -78) across 3 files Reviewer: potatowagon Review duration: 5305m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 310 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.343
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9851"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.3% (MEDIUM) · Higher = larger blast radius
    40.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%
    Repository