Răsfoiți Sursa

Added LinkBalloonPanelView#element to FocusManager.

Oskar Wrobel 9 ani în urmă
părinte
comite
f1675c6fc3

+ 4 - 0
packages/ckeditor5-link/src/link.js

@@ -140,6 +140,10 @@ export default class Link extends Feature {
 		// Create the balloon panel instance.
 		const balloonPanel = new LinkBalloonPanel( panelModel, new LinkBalloonPanelView( editor.locale ) );
 
+		// Add balloonPanel.view#element to FocusManager.
+		// @TODO: Do it automatically ckeditor5-core#23
+		editor.focusManager.add( balloonPanel.view.element );
+
 		// Execute link command after clicking on balloon panel `Link` button.
 		this.listenTo( panelModel, 'executeLink', () => {
 			editor.execute( 'link', balloonPanel.urlInput.value );

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

@@ -168,6 +168,14 @@ describe( 'Link', () => {
 			expect( selectUrlInputSpy.calledOnce ).to.true;
 		} );
 
+		it( 'should add balloon panel element to focus manager', () => {
+			editor.focusManager.isFocused = false;
+
+			balloonPanel.view.element.dispatchEvent( new Event( 'focus' ) );
+
+			expect( editor.focusManager.isFocused ).to.true;
+		} );
+
 		describe( 'binding', () => {
 			it( 'should bind balloonPanel#model to link command', () => {
 				const model = balloonPanel.model;
@@ -405,4 +413,4 @@ function dispatchKeyboardEvent( element, eventName, keyCode ) {
 	event.keyCode = keyCode;
 
 	element.dispatchEvent( event );
-}
+}