Skip to content
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

#6667: Table heading rows should be properly updated after removing rows as a side effect of merging cells #6764

Merged
merged 6 commits into from
May 13, 2020

Conversation

niegowski
Copy link
Contributor

Suggested merge commit message (convention)

Fix (table): Table heading rows should be properly updated after removing rows as a side effect of merging cells. Closes #6667.


Additional information

@niegowski niegowski marked this pull request as draft May 7, 2020 18:43
@niegowski niegowski marked this pull request as ready for review May 8, 2020 11:20
@niegowski niegowski requested a review from jodator May 8, 2020 11:20
@niegowski niegowski changed the title Table heading rows should be properly updated after removing rows as a side effect of merging cells #6667: Table heading rows should be properly updated after removing rows as a side effect of merging cells May 8, 2020
@jodator
Copy link
Contributor

jodator commented May 11, 2020

I've almost merged it with some changes but I had to revert it by force push (sorry for that).

Unfortunatelly it doesn't play well with undo (current master works):

the broken structure is a bug but the other thing is that number of heading rows isn't restored properly or isn't well handled. I had similar case but i can't reproduce it without that broken structure.

Could you check why this happens in this PR? Maybe a merge with master will be enough. The other hint is to check it how remove rows command handle this.

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

Minor changes. Other that that looks good :+1: .

packages/ckeditor5-table/src/commands/mergecellcommand.js Outdated Show resolved Hide resolved
@@ -83,6 +80,8 @@ export default class MergeCellCommand extends Command {
const model = this.editor.model;
const doc = model.document;
const tableCell = getTableCellsContainingSelection( doc.selection )[ 0 ];
const table = findAncestor( 'table', tableCell );
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be moved to if below - AFAICS it will not be needed in other cases.

@@ -57,40 +57,25 @@ export default class MergeCellsCommand extends Command {
updateNumericAttribute( 'colspan', mergeWidth, firstTableCell, writer );
updateNumericAttribute( 'rowspan', mergeHeight, firstTableCell, writer );

const emptyRows = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe emptyRowsIndexes - just to be ultra precise.

packages/ckeditor5-table/src/commands/mergecellscommand.js Outdated Show resolved Hide resolved
}

emptyRows.reverse().forEach( row => tableUtils.removeRows( table, { at: row, batch: writer.batch } ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

And since a table is only needed here maybe a wrap in if( emptyRows.length ) ? But IDK for sure - this can be left as is.

packages/ckeditor5-table/src/tableutils.js Outdated Show resolved Hide resolved
packages/ckeditor5-table/src/tableutils.js Outdated Show resolved Hide resolved
@niegowski niegowski requested a review from jodator May 12, 2020 14:52
@jodator jodator merged commit 72f6491 into master May 13, 2020
@jodator jodator deleted the i/6667 branch May 13, 2020 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merging cells in header do not update heading rows properly
2 participants