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

Image resizer now cleans view after resize is committed/cancelled #122

Merged
merged 12 commits into from
Apr 22, 2020

Conversation

mlewand
Copy link
Contributor

@mlewand mlewand commented Apr 17, 2020

Suggested merge commit message (convention)

Fix: Image resize now cleans up temporary view width style changes. Closes ckeditor/ckeditor5#6060.


Additional information

Reverting should be handled in _cleanup method as it guarantees it to happen whether resize process was committed or cancelled.

@coveralls
Copy link

coveralls commented Apr 17, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling de2922f on i/6060-cleanup into 6273527 on master.

@jodator jodator self-requested a review April 20, 2020 08:49
@jodator jodator self-assigned this Apr 20, 2020
tests/widgetresize.js Outdated Show resolved Hide resolved
Co-Authored-By: Aleksander Nowodzinski <[email protected]>
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.

I've found one UX issue - it flickers (dunno if related to this issue).

src/widgetresize.js Outdated Show resolved Hide resolved
src/widgetresize/resizer.js Outdated Show resolved Hide resolved
this._cleanup();
this._options.onCommit( newValue );
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need to comment on this? Why it is better to commit after cleanup? It looks like it is better to cleanup the view before making changes to it from the model change. Is that it?


const editingView = this._options.editor.editing.view;

editingView.change( writer => {
Copy link
Contributor

@jodator jodator Apr 20, 2020

Choose a reason for hiding this comment

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

I wonder if this is the reason of:

Found on Firefox but also visible on Chrome: after ending resizing the image border of the original size flickers. It happens on every drag (not GIF drops some frames and is not always visible).

What I can think of is a single commit block (if doable) - i.e. wrapping clean-up and commit in a single view change block.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is probably because things are done in two batches and the browser gets a chance to re-pain in between. I don't know how to address this unless I spend some serious time digging into the code.

Copy link
Contributor Author

@mlewand mlewand Apr 21, 2020

Choose a reason for hiding this comment

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

Doh 🤦 @jodator is right. I was a little overconfident with the change and did it only by writing unit test and making a fix. Without realizing there might be some rendering artifacts 😃 Fixed.

@mlewand
Copy link
Contributor Author

mlewand commented Apr 21, 2020

@ckeditor/qa-team Guys can I ask you to double check this little change whether there are no visible regressions vs master?

@mlewand mlewand requested a review from jodator April 21, 2020 07:23
@mlewand
Copy link
Contributor Author

mlewand commented Apr 21, 2020

Tests are passing locally for me, 100% CC. Don't know what's up with the CI. @jodator can you confirm?

@jodator
Copy link
Contributor

jodator commented Apr 21, 2020

@mlewand I can confirm that the test don't work 😜. Merged with master to fix ;)

Could you also add a test to ensure that this change is executed in one view.change() block? Dunno if we have events for that as we can test for similar thing in the model.

@FilipTokarski
Copy link
Member

Tested in all browsers, looks good.

@mlewand
Copy link
Contributor Author

mlewand commented Apr 21, 2020

@mlewand I can confirm that the test don't work 😜. Merged with master to fix ;)

Seems somebody had outdated masters on other repos 🤔

@jodator TBH I'd rather skip on making this test - there's gonna be a major effort to make this TC while this issue was meant to be a quick one.

@Reinmar
Copy link
Member

Reinmar commented Apr 21, 2020

@jodator TBH I'd rather skip on making this test - there's gonna be a major effort to make this TC while this issue was meant to be a quick one.

This is a pretty simple test to write, AFAICT. You just need to listen to the View#render event and check if it was fired once.

As far as I can see from your discussion, this PR proposed an incomplete (buggy) fix, so we should definitely have a test for this scenario. If the mistake could have been done once it can easily be repeated.

@mlewand
Copy link
Contributor Author

mlewand commented Apr 22, 2020

Added the test, I referenced the proper comment to give at least some clarity for a person that faces it in the future.

@Reinmar
Copy link
Member

Reinmar commented Apr 22, 2020

I think that this should be a separate test as we're testing for the number of renders. Also, why 3? That's an odd number.

I'll fix these issues.

@Reinmar
Copy link
Member

Reinmar commented Apr 22, 2020

BTW, when I started digging into this, it turned out that this render count check passes before the issue that it was supposed to cover was fixed. When adding a test, you should verify that it's failing without the thing that you test (like in TDD, but to me it can also be done afterwards).

@Reinmar Reinmar merged commit 92226f9 into master Apr 22, 2020
@Reinmar Reinmar deleted the i/6060-cleanup branch April 22, 2020 21:29
@Reinmar
Copy link
Member

Reinmar commented Apr 22, 2020

I forgot to push the fixed test before merging this PR 🤦. I pushed it to master: edd37d8

mlewand added a commit to ckeditor/ckeditor5 that referenced this pull request May 1, 2020
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.

Image resizer should clean the view after itself
6 participants