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

Switch to dynamically calculated cell map #12288

Merged
merged 7 commits into from
Aug 22, 2022

Conversation

Dumluregn
Copy link
Contributor

Suggested merge commit message (convention)

Internal (table): Calculate the modified cells positions dynamically instead of keeping the static map in the plugin. Closes #12266.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@mlewand mlewand self-requested a review August 22, 2022 13:43
…e notification (the code should always reach change assignment at the end of postfixer loop).
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.

Overall good job with the refactoring. This once unreadable postfixer is now becoming quite nice!

I already discussed the changes with @Dumluregn f2f and we agreed that I'll apply the changes as a part of R.

@@ -206,80 +192,48 @@ export default class TableColumnResizeEditing extends Plugin {
// (1) Adjust the `columnWidths` attribute to guarantee that the sum of the widths from all columns is 100%.
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we go again with the getChangedTables() method name (we already changed it once 😅). Looking fresh at implementation it should be called like getChangedResizedTables() - current name can imply that it's just about any table.


isColumnInsertionHandled = true;
changed = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The changed = true; line seems to be redundant for me. The point of entire if ( columnsCountDelta != 0 ) block is to recalculate columnWidths. As such it should always end up in this final assignment.

Copy link
Contributor

Choose a reason for hiding this comment

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

I removed both lines and no unit test fails which further convince me in this assumption.

const isColumnInsertion = previousColumn < column;
const isColumnDeletion = previousColumn > column;
// If the column count in the table changed, adjust the widths of the affected columns.
const operationType = currentColumnsDelta > 0 ? 'insert' : 'remove';
Copy link
Contributor

Choose a reason for hiding this comment

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

There are just two possible values for this variable and you're using it only for algorithm.

I'd say that a boolean value would be a better choice here. This would result with easier conditions later on. You'd just do

const isAddedColumn = currentColumnsDelta > 0;

And it would be just:

if ( isAddedColumn ) {
	// ...
} else {
	// ...
}

Instead of:

if ( operationType == 'insert' ) {
	// ...
}

if ( operationType == 'remove' ) {
	// ...
}

@mlewand
Copy link
Contributor

mlewand commented Aug 22, 2022

Pushed the changes. I'll wait for CI with merge.

@mlewand mlewand self-requested a review August 22, 2022 15:18
@mlewand mlewand merged commit c1c1754 into ck/epic/11857-table-resize-improvements Aug 22, 2022
@mlewand mlewand deleted the ck/12266-undo-fix branch August 22, 2022 20:37
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.

2 participants