Browse Source

Ensured the Tab key focuses the LinkFormView with the high priority.

Aleksander Nowodzinski 8 năm trước cách đây
mục cha
commit
86fe4b7df1

+ 1 - 1
packages/ckeditor5-link/src/link.js

@@ -213,7 +213,7 @@ export default class Link extends Plugin {
 				this.formView.focus();
 				cancel();
 			}
-		} );
+		}, { priority: 'high' } );
 
 		// Close the panel on the Esc key press when the editable has focus and the balloon is visible.
 		this.editor.keystrokes.set( 'Esc', ( data, cancel ) => {

+ 15 - 1
packages/ckeditor5-link/tests/link.js

@@ -268,7 +268,10 @@ describe( 'Link', () => {
 				viewDocument.render();
 
 				sinon.assert.calledOnce( spy );
-				sinon.assert.calledWithExactly( spy );
+				sinon.assert.calledWithExactly( spy, {
+					target: viewDocument.domConverter.mapViewToDom( root.getChild( 0 ).getChild( 0 ) ),
+					limiter: editorElement
+				} );
 			} );
 
 			// https://github.com/ckeditor/ckeditor5-link/issues/113
@@ -484,6 +487,11 @@ describe( 'Link', () => {
 				stopPropagation: sinon.spy()
 			};
 
+			const normalPriorityTabCallbackSpy = sinon.spy();
+			const highestPriorityTabCallbackSpy = sinon.spy();
+			editor.keystrokes.set( 'Tab', normalPriorityTabCallbackSpy );
+			editor.keystrokes.set( 'Tab', highestPriorityTabCallbackSpy, { priority: 'highest' } );
+
 			// Balloon is invisible, form not focused.
 			formView.focusTracker.isFocused = false;
 
@@ -493,6 +501,8 @@ describe( 'Link', () => {
 			sinon.assert.notCalled( keyEvtData.preventDefault );
 			sinon.assert.notCalled( keyEvtData.stopPropagation );
 			sinon.assert.notCalled( spy );
+			sinon.assert.calledOnce( normalPriorityTabCallbackSpy );
+			sinon.assert.calledOnce( highestPriorityTabCallbackSpy );
 
 			// Balloon is visible, form focused.
 			linkFeature._showPanel( true );
@@ -502,6 +512,8 @@ describe( 'Link', () => {
 			sinon.assert.notCalled( keyEvtData.preventDefault );
 			sinon.assert.notCalled( keyEvtData.stopPropagation );
 			sinon.assert.notCalled( spy );
+			sinon.assert.calledTwice( normalPriorityTabCallbackSpy );
+			sinon.assert.calledTwice( highestPriorityTabCallbackSpy );
 
 			// Balloon is still visible, form not focused.
 			formView.focusTracker.isFocused = false;
@@ -510,6 +522,8 @@ describe( 'Link', () => {
 			sinon.assert.calledOnce( keyEvtData.preventDefault );
 			sinon.assert.calledOnce( keyEvtData.stopPropagation );
 			sinon.assert.calledOnce( spy );
+			sinon.assert.calledTwice( normalPriorityTabCallbackSpy );
+			sinon.assert.calledThrice( highestPriorityTabCallbackSpy );
 		} );
 
 		it( 'should hide the #_balloon after Esc key press (from editor) and not focus the editable', () => {

+ 1 - 1
packages/ckeditor5-link/tests/ui/linkformview.js

@@ -136,7 +136,7 @@ describe( 'LinkFormView', () => {
 		} );
 
 		describe( 'activates keyboard navigation for the toolbar', () => {
-			it( 'so "tab" the next focusable item', () => {
+			it( 'so "tab" focuses the next focusable item', () => {
 				const keyEvtData = {
 					keyCode: keyCodes.tab,
 					preventDefault: sinon.spy(),