Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #194 from ckeditor/t/193
Browse files Browse the repository at this point in the history
Fix: ContextualBalloon.view#element should be registered in editor's focus tracker. Closes #193.
  • Loading branch information
oleq authored Apr 14, 2017
2 parents 28dd457 + 7cf6cd7 commit cfbe329
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 and wait until view will be ready.
return this.editor.ui.view.body.add( this.view );
}
Expand Down
15 changes: 14 additions & 1 deletion tests/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import View from '../../../src/view';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

/* global document, setTimeout */
/* global document, Event, setTimeout */

describe( 'ContextualBalloon', () => {
let editor, editorElement, balloon, viewA, viewB;
Expand Down Expand Up @@ -66,6 +66,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 editor.ui#focusTracker', () => {
editor.ui.focusTracker.isfocused = false;

balloon.add( {
view: viewB,
position: { target: 'fake' }
} );

balloon.view.element.dispatchEvent( new Event( 'focus' ) );

expect( editor.ui.focusTracker.isFocused ).to.true;
} );
} );

describe( 'hasView()', () => {
Expand Down

0 comments on commit cfbe329

Please sign in to comment.