From da1ca90eef0d0a689a97232d5ac677da7fb6e682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wr=C3=B3bel?= Date: Fri, 7 Apr 2017 15:28:25 +0200 Subject: [PATCH 1/2] Registered ContextualToolbar view element in ui focus tracker. --- src/contextualballoon.js | 3 +++ tests/contextualballoon.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/contextualballoon.js b/src/contextualballoon.js index 9586821c..0d66f2f4 100644 --- a/src/contextualballoon.js +++ b/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 ); } diff --git a/tests/contextualballoon.js b/tests/contextualballoon.js index 3b339638..2b442186 100644 --- a/tests/contextualballoon.js +++ b/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()', () => { From ce27248f09d44212fae6b647cfd5e74c4237980f Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Wed, 12 Apr 2017 17:06:22 +0200 Subject: [PATCH 2/2] Tests: Fixed broken ContextualBalloon test. --- tests/panel/balloon/contextualballoon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/panel/balloon/contextualballoon.js b/tests/panel/balloon/contextualballoon.js index f9b9b481..0dcfb868 100644 --- a/tests/panel/balloon/contextualballoon.js +++ b/tests/panel/balloon/contextualballoon.js @@ -66,11 +66,11 @@ describe( 'ContextualBalloon', () => { expect( editor.ui.view.body.getIndex( balloon.view ) ).to.above( -1 ); } ); - it( 'should register balloon panel element in ui focus tracker', () => { + it( 'should register balloon panel element in editor.ui#focusTracker', () => { editor.ui.focusTracker.isfocused = false; balloon.add( { - view: viewA, + view: viewB, position: { target: 'fake' } } );