Skip to content

Commit

Permalink
Fix (find-and-replace): The toolbar should not lose the focus after e…
Browse files Browse the repository at this point in the history
…scaping from the find and replace dropdown. Closes #10420.

Fixing focus after escaping find and replace dropdown
  • Loading branch information
mlewand authored Sep 14, 2021
2 parents 9d74a22 + 2ed4b31 commit a5e0392
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-find-and-replace/src/findandreplaceui.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class FindAndReplaceUI extends Plugin {
// the default action of the drop-down is executed (i.e. the panel showed up). Otherwise,
// the invisible form/input cannot be focused/selected.
//
// Each time a dropdown is closed, move the focus back to the editing root (to preserve it)
// Each time a dropdown is closed, move the focus back to the find and replace toolbar button
// and let the find and replace editing feature know that all search results can be invalidated
// and no longer should be marked in the content.
dropdown.on( 'change:isOpen', ( event, name, isOpen ) => {
Expand All @@ -73,7 +73,7 @@ export default class FindAndReplaceUI extends Plugin {

formView.enableCssTransitions();
} else {
editor.editing.view.focus();
formView.focus();

this.fire( 'searchReseted' );
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-find-and-replace/tests/findandreplaceui.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ describe( 'FindAndReplaceUI', () => {
} );

describe( 'upon dropdown close', () => {
it( 'the editing view should be focused', () => {
it( 'the form should be focused', () => {
dropdown.isOpen = true;

const spy = sinon.spy( editor.editing.view, 'focus' );
const spy = sinon.spy( form, 'focus' );

dropdown.isOpen = false;

Expand Down

0 comments on commit a5e0392

Please sign in to comment.