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

Commit cfbe329

Browse files
authored
Merge pull request #194 from ckeditor/t/193
Fix: ContextualBalloon.view#element should be registered in editor's focus tracker. Closes #193.
2 parents 28dd457 + 7cf6cd7 commit cfbe329

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/panel/balloon/contextualballoon.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export default class ContextualBalloon extends Plugin {
4949
*/
5050
this._stack = new Map();
5151

52+
// Editor should be focused when contextual balloon is focused.
53+
this.editor.ui.focusTracker.add( this.view.element );
54+
5255
// Add balloon panel view to editor `body` collection and wait until view will be ready.
5356
return this.editor.ui.view.body.add( this.view );
5457
}

tests/panel/balloon/contextualballoon.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import View from '../../../src/view';
1010
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
1111
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
1212

13-
/* global document, setTimeout */
13+
/* global document, Event, setTimeout */
1414

1515
describe( 'ContextualBalloon', () => {
1616
let editor, editorElement, balloon, viewA, viewB;
@@ -66,6 +66,19 @@ describe( 'ContextualBalloon', () => {
6666
it( 'should add balloon panel view to editor `body` collection', () => {
6767
expect( editor.ui.view.body.getIndex( balloon.view ) ).to.above( -1 );
6868
} );
69+
70+
it( 'should register balloon panel element in editor.ui#focusTracker', () => {
71+
editor.ui.focusTracker.isfocused = false;
72+
73+
balloon.add( {
74+
view: viewB,
75+
position: { target: 'fake' }
76+
} );
77+
78+
balloon.view.element.dispatchEvent( new Event( 'focus' ) );
79+
80+
expect( editor.ui.focusTracker.isFocused ).to.true;
81+
} );
6982
} );
7083

7184
describe( 'hasView()', () => {

0 commit comments

Comments
 (0)