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

Registered ContextualToolbar view element in ui focus tracker.

Oskar Wróbel 8 лет назад
Родитель
Сommit
d3e61199ae

+ 3 - 0
packages/ckeditor5-ui/src/contextualballoon.js

@@ -49,6 +49,9 @@ export default class ContextualBalloon extends Plugin {
 		 */
 		this._stack = new Map();
 
+		// Editor should be focused when contextual balloon is focused.
+		this.editor.ui.focusTracker.add( this.view.element );
+
 		// Add balloon panel view to editor `body` collection.
 		this.editor.ui.view.body.add( this.view );
 	}

+ 14 - 1
packages/ckeditor5-ui/tests/contextualballoon.js

@@ -11,7 +11,7 @@ import Template from '../src/template';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
-/* global document */
+/* global document, Event */
 
 describe( 'ContextualBalloon', () => {
 	let editor, editorElement, balloon, viewA, viewB;
@@ -57,6 +57,19 @@ describe( 'ContextualBalloon', () => {
 		it( 'should add balloon panel view to editor `body` collection', () => {
 			expect( editor.ui.view.body.getIndex( balloon.view ) ).to.above( -1 );
 		} );
+
+		it( 'should register balloon panel element in ui focus tracker', () => {
+			editor.ui.focusTracker.isfocused = false;
+
+			balloon.add( {
+				view: viewA,
+				position: { target: 'fake' }
+			} );
+
+			balloon.view.element.dispatchEvent( new Event( 'focus' ) );
+
+			expect( editor.ui.focusTracker.isFocused ).to.true;
+		} );
 	} );
 
 	describe( 'hasView()', () => {