瀏覽代碼

Added view focusing after headings command is executed from dropdown.

Szymon Kupś 9 年之前
父節點
當前提交
fe808ce61c
共有 2 個文件被更改,包括 11 次插入0 次删除
  1. 1 0
      packages/ckeditor5-heading/src/headings.js
  2. 10 0
      packages/ckeditor5-heading/tests/headings.js

+ 1 - 0
packages/ckeditor5-heading/src/headings.js

@@ -63,6 +63,7 @@ export default class Headings extends Feature {
 		// Execute command when item from dropdown is selected.
 		this.listenTo( itemListModel, 'execute', ( evt, itemModel ) => {
 			editor.execute( 'headings', itemModel.id );
+			editor.editing.view.focus();
 		} );
 
 		editor.ui.featureComponents.add( 'headings', ListDropdownController, ListDropdownView, dropdownModel );

+ 10 - 0
packages/ckeditor5-heading/tests/headings.js

@@ -59,6 +59,16 @@ describe( 'Headings', () => {
 		sinon.assert.calledWithExactly( executeSpy, 'headings', 'paragraph' );
 	} );
 
+	it( 'should focus view after command execution', () => {
+		const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
+		const controller = editor.ui.featureComponents.create( 'headings' );
+		const model = controller.model.content;
+
+		model.fire( 'execute', { id: 'paragraph', label: 'Paragraph' } );
+
+		sinon.assert.calledOnce( focusSpy );
+	} );
+
 	describe( 'model to command binding', () => {
 		let model, command;