-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lexical-table] Bug Fix: Prevent error if pasted table has empty row #7057
[lexical-table] Bug Fix: Prevent error if pasted table has empty row #7057
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
if (row.getChildrenSize() === 0) { | ||
tableMap[rowIdx] = []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct regarding rowspan, but you can initialize startMapRow
here which will have the same effect and should be correct (at least with regard to that constraint). You'll have to remove the initialization below but I can't put a suggestion on code you didn't change in the review
if (row.getChildrenSize() === 0) { | |
tableMap[rowIdx] = []; | |
} | |
const startMapRow = getMapRow(rowIdx); |
Description
Currently, if a table was pasted that has an empty row, the
$tableTransform
would throw an error. This is because in$computeTableMapSkipCellCheck
, an array for a row is only initialized inside the loop that goes through its children. This causes there to be a gap in the gridMap since an array for the empty row never gets initialized, which then causesgridMap[i]
to be undefined and throw an error.This PR fixes this by making sure an empty array is initialized at the index of the empty row, which in turn will be filled with the necessary amount of cells by
$tableTransform
Test plan
Added e2e test to cover this scenario
Before
After