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

Added additional keystroke handlings for elementspath and toolbar plugins #2412

Closed
wants to merge 21 commits into from

Conversation

jacekbogdanski
Copy link
Member

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

  • Unit tests
  • Manual tests

What changes did you make?

Added additional keystroke handling for elementspath and toolbar. I had some hard time with unit tests for this changes - decided to mock everything instead of more integration testing. The reason is that it's almost impossible to easily test focus change between elementspath, toolbar, and editor.

I also extended the issue with toggling between elementspath and toolbar.

Closes #438

@mlewand mlewand added the review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer. label Sep 13, 2018
@mlewand mlewand self-requested a review September 14, 2018 13:54
@Comandeer Comandeer requested review from Comandeer and removed request for mlewand February 13, 2019 07:07
@Comandeer Comandeer self-assigned this Feb 13, 2019
@Comandeer
Copy link
Member

I've rebased branch onto latest major.

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

Unit tests are failing in IE8.

Additionally please look at https://dev.ckeditor.com/ticket/13168#comment:13 as it provides info about suggested solution.

},

// (#438)
'test focusing editor': function() {
Copy link
Member

Choose a reason for hiding this comment

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

It seems that these tests have common logic, that can be extracted into helper function.

Copy link
Member Author

@jacekbogdanski jacekbogdanski Feb 14, 2019

Choose a reason for hiding this comment

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

I don't know if it's worth it. We will remove very small duplication here because almost half of the test will have to be still configured by arguments (assertion, keystroke, and spy).

Of course, we could extract test code into 2 helper functions shared between toolbar and elementspath test suites, but is it worth effort for such small duplication inside unit tests?

During IE8 bug fix I find out that it requires some custom event handler attribute logic. Extracting it now makes sense.

},

// (#438)
'test focusing editor': function() {
Copy link
Member

Choose a reason for hiding this comment

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

The same here: common logic can be extracted.

case CKEDITOR.ALT + 121: // ALT + F10 (#438).
editor.execCommand( 'toolbarFocus' );
return false;
case CKEDITOR.ALT + 122: // ALT + F11 (#438).
Copy link
Member

Choose a reason for hiding this comment

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

There is already case for focusing editor. Additionally I'm not sure if we really need it, as Esc already handles it.

case CKEDITOR.ALT + 122: // ALT + F11 (#438).
editor.execCommand( 'elementsPathFocus' );
return false;
case CKEDITOR.ALT + 121: // ALT + F10 (#438).
Copy link
Member

Choose a reason for hiding this comment

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

The same here: there is already case for focusing editor.

@@ -0,0 +1,31 @@
@bender-ui: collapsed
@bender-tags: 4.11.0, 438, bug
Copy link
Member

Choose a reason for hiding this comment

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

Please update version tag.

@@ -0,0 +1,31 @@
@bender-ui: collapsed
@bender-tags: 4.11.0, 438, bug
Copy link
Member

Choose a reason for hiding this comment

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

Please update version tag.

@@ -0,0 +1,31 @@
@bender-ui: collapsed
Copy link
Member

Choose a reason for hiding this comment

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

Actually is this test needed? It seems the same as tests/plugins/elementspath/manual/focus.md.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like rebase artifact, I will remove it right away.

@@ -0,0 +1,31 @@
@bender-ui: collapsed
@bender-tags: 4.11.0, 438, bug
Copy link
Member

Choose a reason for hiding this comment

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

Please update version tag.

@Comandeer Comandeer removed their assignment Feb 14, 2019
@jacekbogdanski jacekbogdanski self-assigned this Feb 14, 2019
@jacekbogdanski
Copy link
Member Author

Unfortunately, IE8 is unable to resolve event object when element event attribute handler is executed directly on the element (which is required to test this case). I find out a workaround for this issue, although it requires some small but tricky code. I moved it into a separate helper function.

* @param {String} eventName Event handler attribute name.
* @param {Object} evt Event payload.
*/
function fireElementEventHandler( element, eventName, evt ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Helper copied and moved to bender.tools.fireElementEventHandler. More details: #2828

@msamsel
Copy link
Contributor

msamsel commented Feb 20, 2019

I reuse helper (fireElementEventHandler) proposed in this PR to fix failing test during release.
More details: #2828

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. review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to navigate to editable from toolbar by keyboard and vice versa
4 participants