Skip to content

Commit

Permalink
Merge pull request #12990 from ckeditor/ck/12939-fix-find-and-replace…
Browse files Browse the repository at this point in the history
…-in-source-editing-mode

Fix (find-and-replace): Disable the find and replace popup in source mode. Closes #12939.
  • Loading branch information
arkflpc authored Dec 8, 2022
2 parents 30acb8f + f274db8 commit d7885a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ckeditor5-find-and-replace/src/findandreplaceui.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export default class FindAndReplaceUI extends Plugin {
} );

editor.keystrokes.set( 'Ctrl+F', ( data, cancelEvent ) => {
dropdown.isOpen = true;
cancelEvent();
if ( dropdown.isEnabled ) {
dropdown.isOpen = true;
cancelEvent();
}
} );
}

Expand Down
22 changes: 22 additions & 0 deletions packages/ckeditor5-find-and-replace/tests/findandreplaceui.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,28 @@ describe( 'FindAndReplaceUI', () => {
expect( dropdown.buttonView.keystroke ).to.equal( 'CTRL+F' );
} );

it( 'should not open the dropdown when command is disabled and CTRL+F was pressed', () => {
findCommand.isEnabled = false;

expect( dropdown.isOpen ).to.be.false;
expect( dropdown.isEnabled ).to.be.false;

const keyEventData = ( {
keyCode: keyCodes.f,
ctrlKey: !env.isMac,
metaKey: env.isMac,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

const wasHandled = editor.keystrokes.press( keyEventData );

expect( wasHandled ).to.be.true;
expect( keyEventData.preventDefault.notCalled ).to.be.true;

expect( dropdown.isOpen ).to.be.false;
} );

it( 'should open the dropdown when CTRL+F was pressed', () => {
const spy = sinon.spy( form._findInputView.fieldView, 'select' );

Expand Down

0 comments on commit d7885a5

Please sign in to comment.