8
0
Просмотр исходного кода

Added comments and refactoring

Paweł Kwaśnik 5 лет назад
Родитель
Сommit
a9be9a30b7

+ 3 - 0
packages/ckeditor5-image/src/imageinsert/imageinsertui.js

@@ -113,6 +113,9 @@ export default class ImageInsertUI extends Plugin {
 					insertImageViaUrlForm.label = t( 'Insert image via URL' );
 				}
 			}
+		// Note: Use the low priority to make sure the following listener starts working after the
+		// default action of the drop-down is executed (i.e. the panel showed up). Otherwise, the
+		// invisible form/input cannot be focused/selected.
 		}, { priority: 'low' } );
 
 		imageInsertView.delegate( 'submit', 'cancel' ).to( dropdownView );

+ 4 - 2
packages/ckeditor5-image/tests/imageinsert/imageinsertui.js

@@ -282,9 +282,11 @@ describe( 'ImageInsertUI', () => {
 			it( 'should focus on "insert image via URL" input after opening', () => {
 				let spy;
 
+				// The ImageInsertPanelView is added on first open.
+				// See https://github.com/ckeditor/ckeditor5/pull/8019#discussion_r484069652
 				dropdown.on( 'change:isOpen', () => {
-					const first = dropdown.panelView.children.first;
-					spy = sinon.spy( first, 'focus' );
+					const imageInsertPanelView = dropdown.panelView.children.first;
+					spy = sinon.spy( imageInsertPanelView, 'focus' );
 				}, { priority: 'highest' } );
 
 				dropdown.buttonView.fire( 'open' );