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

Set correct focus on tab in dialog when is clicked #3499

Merged
merged 34 commits into from
Dec 4, 2019
Merged

Set correct focus on tab in dialog when is clicked #3499

merged 34 commits into from
Dec 4, 2019

Conversation

msamsel
Copy link
Contributor

@msamsel msamsel commented Sep 25, 2019

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 is the proposed changelog entry for this pull request?

* [#3474](https://github.com/ckeditor/ckeditor4/issues/3474): Fixed: Incorrect focus order after tab in dialog navigation was clicked.
* [#3689](https://github.com/ckeditor/ckeditor4/issues/3689): Fixed: Cannot change dialog tabs focus with keyboard arrows after focusing with any tab with mouse click.

What changes did you make?

After clicking into the tab in navigation setup a proper focus and state.
There is also some clean up to prevent jshint errors.

Closes: #3474, closes: #3689

@msamsel msamsel changed the base branch from major to master September 27, 2019 15:01
@msamsel msamsel force-pushed the t/3474 branch 2 times, most recently from 020b94c to cef63ba Compare October 1, 2019 10:51
@msamsel msamsel marked this pull request as ready for review October 1, 2019 10:56
@f1ames f1ames self-requested a review October 2, 2019 14:19
@f1ames f1ames self-assigned this Oct 2, 2019
@f1ames
Copy link
Contributor

f1ames commented Nov 21, 2019

Rebased onto latest master.

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Generally, the fix looks good - it slightly changes focusing behaviour, but from what I see it makes it more consistent. Some polishing in dialogTools still needs to be done.

plugins/dialog/plugin.js Show resolved Hide resolved
tests/_benderjs/ckeditor/static/bot.js Show resolved Hide resolved
}, 0 );
} );

CKEDITOR.tools.setTimeout( function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This timeout will be still executed even after resolve is done. You should save store object which is returned by CKEDITOR.tools.setTimeout and cancel timeout execution before resolve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Promises should be resilient to such cases, as a single promise cannot be resolved or rejected twice. But as we are using polyfills and cleaning up unnecessary functions is a good practice I add the cleaning up mechanism.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you can't resolve/reject promise more than one time or rejected already resolved promise. Still, it's good practise to cleanup code in such cases as above.

tests/plugins/dialog/_helpers/tools.js Outdated Show resolved Hide resolved
tests/plugins/dialog/_helpers/tools.js Outdated Show resolved Hide resolved
tests/plugins/dialog/focus.js Outdated Show resolved Hide resolved
tests/plugins/dialog/_helpers/tools.js Outdated Show resolved Hide resolved
tests/plugins/dialog/_helpers/tools.js Outdated Show resolved Hide resolved
tests/plugins/dialog/_helpers/tools.js Outdated Show resolved Hide resolved
tests/plugins/dialog/focus.js Show resolved Hide resolved
@msamsel msamsel self-assigned this Nov 27, 2019
@msamsel
Copy link
Contributor Author

msamsel commented Nov 28, 2019

I didn't rebase the branch to not lose the comments history. But I check it locally and it rebases without any issue.

@msamsel msamsel removed their assignment Nov 28, 2019
@msamsel msamsel requested a review from f1ames November 28, 2019 15:31
@f1ames f1ames self-assigned this Nov 29, 2019
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Submitting first review part (review still pending).

tests/_benderjs/ckeditor/static/bot.js Show resolved Hide resolved
tests/_benderjs/ckeditor/static/bot.js Show resolved Hide resolved
tests/_benderjs/ckeditor/static/bot.js Outdated Show resolved Hide resolved
tests/_benderjs/ckeditor/static/bot.js Outdated Show resolved Hide resolved
tests/_benderjs/ckeditor/static/bot.js Outdated Show resolved Hide resolved
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

I only did some minor refactoring in dialog tools. It looks quite impressive and the way how easily we can now test dialogs is really nice, good job 👍

Just some minor polishing in tests left (see #3499 (review)). Also I wonder, do you see in benefit in creating more integrational tests (so testing focus on some real plugins dialogs instead of test dialogs)?

@msamsel
Copy link
Contributor Author

msamsel commented Dec 3, 2019

Also I wonder, do you see in benefit in creating more integrational tests (so testing focus on some real plugins dialogs instead of test dialogs)?

It's a great idea. I tried to do it within this PR, however, I noticed it would require to attach my custom focusChange event to all default dialogs. That's why it won't be super easy, however, it seems to be doable in a reasonable time. I extract this as a separate task, with a description what should be done and link it to this task.

@msamsel
Copy link
Contributor Author

msamsel commented Dec 3, 2019

Helper improvements and extra unit tests are extracted to #3706.

@msamsel msamsel requested a review from f1ames December 4, 2019 08:15
@f1ames f1ames self-assigned this Dec 4, 2019
Mateusz Samsel and others added 23 commits December 4, 2019 09:44
… be confusing and replace it with comment in code.
…ly initialized and focus remain on cancel button. Provide config to the test editor to have always the same order of buttons regardles of OS.
Co-Authored-By: Krzysztof Krztoń <[email protected]>
@f1ames
Copy link
Contributor

f1ames commented Dec 4, 2019

Rebased onto latest master.

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

LGTM, good job 👍

@f1ames f1ames merged commit 1ff8ee2 into master Dec 4, 2019
@CKEditorBot CKEditorBot deleted the t/3474 branch December 4, 2019 09:26
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