-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix disappearing undo steps after multiple selection changes #2792
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good, just some minor things.
I've found one more case which is even worse than originally reported. It is covered by your fix, but could you add test for that case too?
|
||
editable.attachListener( mouseupHost, 'mouseup', function( evt ) { | ||
if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT ) { | ||
if ( getMouseButton( evt ) === CKEDITOR.MOUSE_BUTTON_LEFT && cmd.state === CKEDITOR.TRISTATE_ON ) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -0,0 +1,13 @@ | |||
@bender-ui: collapsed | |||
@bender-tags: bug, copyformatting, 4.11.3, trac16675 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong issue reference number.
@bender-tags: bug, copyformatting, 4.11.3, trac16675 | |
@bender-tags: bug, copyformatting, 4.11.3, 2780 |
@bender-ckeditor-plugins: copyformatting, toolbar, wysiwygarea, undo, basicstyles | ||
|
||
## Test both editors | ||
1. Add some content to editor (e.g. new line), to "avctivate" undo step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
1. Add some content to editor (e.g. new line), to "avctivate" undo step. | |
1. Add some content to editor (e.g. new line), to "activate" undo step. |
}; | ||
|
||
bender.test( { | ||
'test undo integration': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment with ticket reference.
I add test cases which covers "redo" issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just few more small things.
@@ -11,6 +12,26 @@ | |||
} | |||
}; | |||
|
|||
function prepareEditor( bot ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the function below bender.test
, as we agreed to keep function declaration at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if prepareEditor
name works here. This function has plenty asserts and they aren't part of preparing editor.
CKEDITOR.replace( 'editor1' ); | ||
CKEDITOR.replace( 'editor1', { | ||
on: { | ||
instanceReady: function( evt ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listener function could be extracted to avoid duplicate code.
Additionally variable declarations could be grouped.
|
||
## Test both editors | ||
1. Add some content to editor (e.g. new line), to "activate" undo step. | ||
2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that adding empty lines between each test step improves readability.
instanceReady: function( evt ) { | ||
var editor = evt.editor; | ||
var currentIndicator = CKEDITOR.document.findOne( '#ed1-current' ); | ||
editor.editable().on( 'mouseup', function( evt ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evt
param is unused, could be omitted.
1. Add some content to editor (e.g. new line), to "activate" undo step. | ||
2. Start to click around editor to change selection inside editor (20-25 times). Selection have to differ between adjacent steps. | ||
### Expected: | ||
Undo UI button is active. Current snapshot index does equals 1 and doesn't change with selection change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't change with selection change.
It updates only on mouse event so it's hard to tell if it's because of selection change or not. If we can't use other event like change
maybe just go with interval. It will be much more convenient if index preview update weren't limited to user action.
} | ||
|
||
assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on 1st step.' ); | ||
assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.isTrue( editor.undoManager.undoable(), 'Editor should has possibility to undo.' ); | |
assert.isTrue( editor.undoManager.undoable(), 'Editor should have a possibility to undo.' ); |
} ) ); | ||
} | ||
|
||
assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on 1st step.' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on 1st step.' ); | |
assert.areSame( 1, editor.undoManager.index, 'There shouldn\'t be new undo steps and editor should remain on the 1st step.' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setInterval
doesn't improve test, as second (after initial) snapshot is created when selection changes so it might be misleading for tester when he types something and index preview updates on click. Maybe we should just drop the preview of snapshot index and just repeat steps from originally reported issue.
PR related to: #2811 |
I cherry-picked tests from #2811. I've also updated unit test for undo to behave correctly in IE 8 (as it uses non-standard code for left mouse button). |
…st helpr to be more accurate.
… might confuse the user during testing phase.
Co-Authored-By: Comandeer <[email protected]>
… to make code simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
What is the purpose of this pull request?
Bug fix
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
What changes did you make?
applyFormat
command after mouse up event, when there is no stored formatting.Closes #2780.
Closes #2655.
Closes #2470.