diff --git a/src/link.js b/src/link.js index 6c1a13d..c99908a 100644 --- a/src/link.js +++ b/src/link.js @@ -132,7 +132,10 @@ export default class Link extends Plugin { const t = editor.t; // Handle the `Ctrl+K` keystroke and show the panel. - editor.keystrokes.set( linkKeystroke, () => { + editor.keystrokes.set( linkKeystroke, ( keyEvtData, cancel ) => { + // Prevent focusing the search bar in FF and opening new tab in Edge. #153, #154. + cancel(); + if ( linkCommand.isEnabled ) { this._showPanel( true ); } diff --git a/tests/link.js b/tests/link.js index ebab8f8..a160598 100644 --- a/tests/link.js +++ b/tests/link.js @@ -442,14 +442,39 @@ describe( 'Link', () => { const command = editor.commands.get( 'link' ); command.isEnabled = false; - editor.keystrokes.press( { keyCode: keyCodes.k, ctrlKey: true } ); + editor.keystrokes.press( { + keyCode: keyCodes.k, + ctrlKey: true, + preventDefault: sinon.spy(), + stopPropagation: sinon.spy() + } ); sinon.assert.notCalled( spy ); command.isEnabled = true; - editor.keystrokes.press( { keyCode: keyCodes.k, ctrlKey: true } ); + editor.keystrokes.press( { + keyCode: keyCodes.k, + ctrlKey: true, + preventDefault: sinon.spy(), + stopPropagation: sinon.spy() + } ); sinon.assert.calledWithExactly( spy, true ); } ); + it( 'should prevent default action on Ctrl+K keystroke', () => { + const preventDefaultSpy = sinon.spy(); + const stopPropagationSpy = sinon.spy(); + + editor.keystrokes.press( { + keyCode: keyCodes.k, + ctrlKey: true, + preventDefault: preventDefaultSpy, + stopPropagation: stopPropagationSpy + } ); + + sinon.assert.calledOnce( preventDefaultSpy ); + sinon.assert.calledOnce( stopPropagationSpy ); + } ); + it( 'should focus the the #formView on `Tab` key press when the #_balloon is open', () => { const keyEvtData = { keyCode: keyCodes.tab,