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

Remove progress bar during snapshot creation #1602

Closed
wants to merge 8 commits into from
Closed

Conversation

f1ames
Copy link
Contributor

@f1ames f1ames commented Feb 7, 2018

What is the purpose of this pull request?

Task

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

Progress bar is now removed from HTML during snapshot creation so it does not pollute the images causing undo manager to think something changes.

Partially addresses #1532.

@f1ames
Copy link
Contributor Author

f1ames commented Feb 7, 2018

As Easy Image was merged to major already, I targeted this PR there too.

@f1ames
Copy link
Contributor Author

f1ames commented Feb 7, 2018

This PR does not solve all udno integration problems, but only one in which progress bar HTML (which changes due to tracking upload progress), causes undoManager to save new snapshots, because of changes in HTML (caused by progress bar progress).

See more in #1532.


**Saved undo steps** counter should not increment on selection manipulation.

**Important**: Selecting or deselecting widget will create an undo step.
Copy link
Member

Choose a reason for hiding this comment

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

Honestly I don't understand these instructions.

First of all, upload is too quick to allow sensible "selection manipulation". Maybe mocking it with slowed progress would be a good idea?

What's more, how to check if counter does not change, when every selection change will change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slowing down an upload makes sense, as network speed throttling is only available on Chrome (and probably you will need 10mb image to test it properly without it).

As for selection change adding snapshot, I'm not sure, tested it on Chrome, FF, Safari, IE11 and it seems pure selection changes does not cause new undo step:

feb-08-2018 11-40-48

Maybe there are some particular cases in which id does and some in which it doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a case with selecting/deselecting widget which triggers undo snapshot, but it is already covered in tests description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are also other cases, like select all. Relaying on undo snapshots count may be misleading. I redesigned the test to check if latest created snapshot contains progressbar.

@f1ames f1ames requested a review from Comandeer February 8, 2018 11:43
@mlewand mlewand added this to the 4.9.1 milestone Feb 8, 2018
@mlewand
Copy link
Contributor

mlewand commented Feb 8, 2018

We won't be able to contain this in the upcomin release. Let's move it to 4.9.1 instead.

var remove = this.remove;
this.remove = function() {
// Remove undo listeners when progress bar is removed.
CKEDITOR.tools.array.filter( undoListeners, function( listener ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why filter is used here? It does not modify original array, so it's left untouched, with all listeners inside. CKEDITOR.tools.array.forEach + undoListener.length = 0 seems like a better alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like some leftover after poor copy/paste 😭

// (as content will be changed due to progressbar progress).
undoListeners.push(
editor.on( 'beforeUndoImage', function() {
if ( this.wrapper.getParent() ) {
Copy link
Member

Choose a reason for hiding this comment

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

This function could be simplified by early return if this.wrapper does not have a parent.


loader.uploadTotal = 10;

updateLoader( loader, 2, function() {
Copy link
Member

Choose a reason for hiding this comment

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

This whole part of tests is very repetitve. I'd extract it to dedicated helper function.

@f1ames f1ames requested a review from Comandeer February 20, 2018 13:47
@mlewand mlewand modified the milestones: 4.9.1, Backlog Mar 12, 2018
@Comandeer
Copy link
Member

I've rebased to latest major and update tests.

@mlewand mlewand self-requested a review April 10, 2018 13:08
@mlewand
Copy link
Contributor

mlewand commented Apr 10, 2018

Taking over the review.

@mlewand mlewand added the review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer. label Jul 18, 2018
@f1ames f1ames added pr:frozen ❄ The pull request on which work was suspended due to various reasons. and removed review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer. labels Aug 30, 2019
@f1ames
Copy link
Contributor Author

f1ames commented Aug 30, 2019

I have revisited this PR and it looks like some minor thing. Since Easy Image plugin is publicly available for some significant amount of time already and we didn't have any similar issue reports it is a low priority.

As for the solution itself we can continue with the above (it's 1,5 year old so may need some updates) or try to address this with undoManager.filter (#3245) mechanism which was recently introduced.

@f1ames f1ames closed this Aug 30, 2019
@f1ames f1ames removed this from the Backlog milestone Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:frozen ❄ The pull request on which work was suspended due to various reasons.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants