Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

I/6406: Fix logic behind removing multiple columns or rows in a row #286

Merged
merged 7 commits into from
Mar 26, 2020

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Mar 25, 2020

Suggested merge commit message (convention)

Fix: Recalculate table geometry on each row or column removal. Closes ckeditor/ckeditor5#6406.


Additional information

I've noticed that the tableMap was passed but it is static. You must get the table map after each row/column removal for loop operations otherwise the remove row/column algorithm would work on obsolete data.

@jodator jodator requested a review from mlewand March 25, 2020 09:03
@coveralls
Copy link

coveralls commented Mar 25, 2020

Coverage Status

Coverage increased (+2.0e-05%) to 99.935% when pulling ba5b314 on i/6406 into 49ad106 on master.

@Reinmar
Copy link
Member

Reinmar commented Mar 25, 2020

I'm not going to lie to you – this is not something I want to verify by analysing the implementation 🤣I've briefly scanned the code but that's it.

cc @ckeditor/qa-team, could you go through the various cases that were failing recently and perhaps some more?

@jodator
Copy link
Contributor Author

jodator commented Mar 26, 2020

I'm not going to lie to you – this is not something I want to verify by analysing the implementation

Sure - the change was minimal actually - regenerate tableMap by calling new TableWalker() after each row/column removal. Otherwise the algorithm was analysing obsolete data.

@FilipTokarski
Copy link
Member

FilipTokarski commented Mar 26, 2020

Sometimes when the table has complex geometry and you remove a row ( with multiselect or not ), cells are changing their position in table:

26_table1

26_table3

@jodator
Copy link
Contributor Author

jodator commented Mar 26, 2020

Sometimes when the table has complex geometry and you remove a row ( with multiselect or not )

If this happens for one row selection then it looks like a bug in the original remove row algorithm. So if nothing similar happens I'm confident that this change is OK. I'd move the above case as a general table issue because it looks like an edge case as those spans are tough.

BTW, thanks for coloured samples - it is so easy to spot what's happening in the case :)

@Mgsy
Copy link
Member

Mgsy commented Mar 26, 2020

We've tested it and changes look good 👍

@mlewand mlewand self-assigned this Mar 26, 2020
Copy link
Contributor

@mlewand mlewand left a comment

Choose a reason for hiding this comment

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

Indeed refreshing the table map for each iteration was what we needed 👍 works much better now, LGTM.

There was one detail with the variable name which I'll push in a second and merge.

const rowIndexes = tableMap.filter( entry => selectedCells.includes( entry.cell ) ).map( el => el.row );
const minRowIndex = rowIndexes[ 0 ];
const maxRowIndex = rowIndexes[ rowIndexes.length - 1 ];
const removedRowIndexes = getRowIndexes( selectedCells );
Copy link
Contributor

Choose a reason for hiding this comment

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

These cells are not yet removed, these are selected cells that are about to be removed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing complex colspan/rowspan multi-cell selections column/rows should be improved
6 participants