Skip to content

Commit

Permalink
Merge pull request #8212 from ckeditor/i/7919
Browse files Browse the repository at this point in the history
Fix (link): Do not show up link UI on <kbd>Ctrl</kbd>+<kbd>K</kbd> when `LinkCommand` is disabled. Closes #7919.
  • Loading branch information
jodator committed Oct 6, 2020
2 parents 37b481e + 409296a commit 242d21c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ckeditor5-link/src/linkui.js
Expand Up @@ -219,7 +219,9 @@ export default class LinkUI extends Plugin {
// Prevent focusing the search bar in FF, Chrome and Edge. See https://github.com/ckeditor/ckeditor5/issues/4811.
cancel();

this._showUI( true );
if ( linkCommand.isEnabled ) {
this._showUI( true );
}
} );

editor.ui.componentFactory.add( 'link', locale => {
Expand Down
15 changes: 15 additions & 0 deletions packages/ckeditor5-link/tests/linkui.js
Expand Up @@ -795,6 +795,21 @@ describe( 'LinkUI', () => {
sinon.assert.calledWithExactly( spy, true );
} );

it( 'should not show the UI on Ctrl+K keystroke on content with LinkCommand disabled', () => {
const spy = testUtils.sinon.stub( linkUIFeature, '_showUI' ).returns( {} );
const command = editor.commands.get( 'link' );
command.isEnabled = false;

editor.keystrokes.press( {
keyCode: keyCodes.k,
ctrlKey: true,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

sinon.assert.notCalled( spy );
} );

it( 'should prevent default action on Ctrl+K keystroke', () => {
const preventDefaultSpy = sinon.spy();
const stopPropagationSpy = sinon.spy();
Expand Down

0 comments on commit 242d21c

Please sign in to comment.