8
0
Pārlūkot izejas kodu

Focusing the URL input when the image upload panel shows up

Paweł Kwaśnik 5 gadi atpakaļ
vecāks
revīzija
a6158ad11b

+ 1 - 1
packages/ckeditor5-image/src/imageinsert/imageinsertui.js

@@ -113,7 +113,7 @@ export default class ImageInsertUI extends Plugin {
 					insertImageViaUrlForm.label = t( 'Insert image via URL' );
 				}
 			}
-		} );
+		}, { priority: 'low' } );
 
 		imageInsertView.delegate( 'submit', 'cancel' ).to( dropdownView );
 		this.delegate( 'cancel' ).to( dropdownView );

+ 12 - 0
packages/ckeditor5-image/tests/imageinsert/imageinsertui.js

@@ -278,6 +278,18 @@ describe( 'ImageInsertUI', () => {
 				sinon.assert.notCalled( commandSpy );
 				sinon.assert.calledOnce( cancelSpy );
 			} );
+
+			it( 'should focus on "insert image via URL" input after opening', () => {
+				let spy;
+
+				dropdown.on( 'change:isOpen', () => {
+					const first = dropdown.panelView.children.first;
+					spy = sinon.spy( first, 'focus' );
+				}, { priority: 'highest' } );
+
+				dropdown.buttonView.fire( 'open' );
+				sinon.assert.calledOnce( spy );
+			} );
 		} );
 
 		it( 'should inject integrations to the dropdown panel view from the config', async () => {