Przeglądaj źródła

Merge branch 'master' into t/7

Piotrek Koszuliński 6 lat temu
rodzic
commit
ed574fc913

+ 3 - 1
packages/ckeditor5-mention/src/mentionui.js

@@ -205,13 +205,15 @@ export default class MentionUI extends Plugin {
 			const start = end.getShiftedBy( -matchedTextLength );
 			const range = model.createRange( start, end );
 
+			this._hidePanelAndRemoveMarker();
+
 			editor.execute( 'mention', {
 				mention: item,
 				marker,
 				range
 			} );
 
-			this._hidePanelAndRemoveMarker();
+			editor.editing.view.focus();
 		} );
 
 		return mentionsView;

+ 17 - 0
packages/ckeditor5-mention/tests/mentionui.js

@@ -966,6 +966,23 @@ describe( 'MentionUI', () => {
 					expect( editor.model.markers.has( 'mention' ) ).to.be.false;
 				} );
 		} );
+
+		it( 'should focus view after command execution', () => {
+			const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
+
+			setData( model, '<paragraph>foo []</paragraph>' );
+
+			model.change( writer => {
+				writer.insertText( '@', doc.selection.getFirstPosition() );
+			} );
+
+			return waitForDebounce()
+				.then( () => {
+					listView.items.get( 0 ).children.get( 0 ).fire( 'execute' );
+
+					sinon.assert.calledOnce( focusSpy );
+				} );
+		} );
 	} );
 
 	function createClassicTestEditor( mentionConfig ) {