[lexical-table] Bug Fix: The plain text of a table selection holds the text of a nested table once #9869
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 208 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.320
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9869"
general
weight: 0.35
potatowagon
Description
When copying or cutting a table selection that contains a nested table, the nested table's text was appearing twice in the
text/plainoutput.The issue was in
TableSelection.getTextContent(). It was collecting everyTableCellNodereturned bygetNodes(), which also included cells from nested tables. Since the outer cell's text already contained the nested table's content, those nested cells were being added again, resulting in duplicate text. It also affected the tab spacing between cells that followed, since nested cells belong to a different row.This change fixes the issue by making
getTextContent()consider only cells that belong to the selected table. The same filtering is applied both when collecting the cells and when building the final text output.Rows with no directly selected cells still retain their blank lines, so the existing formatting behavior is preserved. The HTML and Lexical JSON output were already correct and are unaffected by this change.
For example, consider a 2x2 table (
A B / C D) where cellAcontains a nested table with the textINNER. When selecting the entire table, the plain text output previously looked like this:It now produces the expected output:
Closes #9755
Changeset
Added
.changeset/table-selection-nested-text.mdwith a patch changeset for@lexical/table, including a[fix]entry and aVerify:paragraph.Test plan
Before
https://github.com/user-attachments/assets/fc6b830e-99de-4a84-a211-03d461756bc2
After
https://github.com/user-attachments/assets/58633ef0-0156-4181-9dce-598de47a4a91