Przeglądaj źródła

Focus the editable before closing link balloon panels.

Oskar Wróbel 6 lat temu
rodzic
commit
eb4f7a7b2f

+ 5 - 3
packages/ckeditor5-link/src/linkui.js

@@ -365,14 +365,16 @@ export default class LinkUI extends Plugin {
 
 		this.stopListening( editor.ui, 'update' );
 
+		// Make sure the focus always gets back to the editable
+		// before removing currently focused views.
+		// See https://github.com/ckeditor/ckeditor5-link/issues/193.
+		editor.editing.view.focus();
+
 		// Remove form first because it's on top of the stack.
 		this._removeFormView();
 
 		// Then remove the actions view because it's beneath the form.
 		this._balloon.remove( this.actionsView );
-
-		// Make sure the focus always gets back to the editable.
-		editor.editing.view.focus();
 	}
 
 	/**

+ 10 - 0
packages/ckeditor5-link/tests/linkui.js

@@ -416,6 +416,16 @@ describe( 'LinkUI', () => {
 			sinon.assert.calledTwice( spy );
 		} );
 
+		// https://github.com/ckeditor/ckeditor5-link/issues/193
+		it( 'should focus the `editable` before before removing elements from the balloon', () => {
+			const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
+			const removeSpy = testUtils.sinon.spy( balloon, 'remove' );
+
+			linkUIFeature._hideUI();
+
+			expect( focusSpy.calledBefore( removeSpy ) ).to.equal( true );
+		} );
+
 		it( 'should not throw an error when views are not in the `balloon`', () => {
 			linkUIFeature._hideUI();