Skip to content

Commit

Permalink
Merge pull request #7306 from ckeditor/i/6394
Browse files Browse the repository at this point in the history
Other (mention): The space key will not confirm a mention selection from the list. Closes #6394.
  • Loading branch information
jodator authored Aug 18, 2020
2 parents 0bd756c + 0f30487 commit a8d41ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/ckeditor5-mention/src/mentionui.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const handledKeyCodes = [
keyCodes.arrowdown,
keyCodes.enter,
keyCodes.tab,
keyCodes.space,
keyCodes.esc
];

Expand Down Expand Up @@ -121,7 +120,7 @@ export default class MentionUI extends Plugin {
this._mentionsView.selectPrevious();
}

if ( data.keyCode == keyCodes.enter || data.keyCode == keyCodes.tab || data.keyCode == keyCodes.space ) {
if ( data.keyCode == keyCodes.enter || data.keyCode == keyCodes.tab ) {
this._mentionsView.executeSelected();
}

Expand Down
28 changes: 23 additions & 5 deletions packages/ckeditor5-mention/tests/mentionui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,30 @@ describe( 'MentionUI', () => {
testExecuteKey( 'enter', keyCodes.enter, feedItems );

testExecuteKey( 'tab', keyCodes.tab, feedItems );
} );

describe( 'on other keys', () => {
it( 'should do nothing on space', async () => {
setData( model, '<paragraph>foo []</paragraph>' );

model.change( writer => {
writer.insertText( '@', doc.selection.getFirstPosition() );
} );

const command = editor.commands.get( 'mention' );
const spy = testUtils.sinon.spy( command, 'execute' );

await waitForDebounce();
expectChildViewsIsOnState( [ true, false, false, false, false ] );

testExecuteKey( 'space', keyCodes.space, feedItems );
fireKeyDownEvent( {
keyCodes: keyCodes.space,
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
} );

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

Expand Down Expand Up @@ -1724,8 +1746,6 @@ describe( 'MentionUI', () => {
testExecuteKey( 'enter', keyCodes.enter, issues );

testExecuteKey( 'tab', keyCodes.tab, issues );

testExecuteKey( 'space', keyCodes.space, issues );
} );
} );
} );
Expand Down Expand Up @@ -1849,8 +1869,6 @@ describe( 'MentionUI', () => {
testExecuteKey( 'enter', keyCodes.enter, issues );

testExecuteKey( 'tab', keyCodes.tab, issues );

testExecuteKey( 'space', keyCodes.space, issues );
} );

describe( 'mouse', () => {
Expand Down

0 comments on commit a8d41ec

Please sign in to comment.