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

Merge pull request #38 from ckeditor/t/36

Added LinkBalloonPanelView#element to FocusTracker.
Aleksander Nowodzinski 9 лет назад
Родитель
Сommit
ba4d41d60a

+ 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 FocusTracker.
+		// @TODO: Do it automatically ckeditor5-core#23
+		editor.focusTracker.add( balloonPanel.view.element );
+
 		// Execute link command after clicking on balloon panel `Link` button.
 		this.listenTo( panelModel, 'executeLink', () => {
 			editor.execute( 'link', balloonPanel.urlInput.value );

+ 1 - 3
packages/ckeditor5-link/src/ui/linkballoonpanel.js

@@ -177,9 +177,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 
 		unlinkModel.on( 'execute', () => this.model.fire( 'executeUnlink' ) );
 
-		const button = new Button( unlinkModel, new ButtonView( this.locale ) );
-
-		return button;
+		return new Button( unlinkModel, new ButtonView( this.locale ) );
 	}
 }
 

+ 8 - 0
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 tracker', () => {
+			editor.focusTracker.isFocused = false;
+
+			balloonPanel.view.element.dispatchEvent( new Event( 'focus' ) );
+
+			expect( editor.focusTracker.isFocused ).to.true;
+		} );
+
 		describe( 'binding', () => {
 			it( 'should bind balloonPanel#model to link command', () => {
 				const model = balloonPanel.model;