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

Disable find and replace popup in source mode. #12990

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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