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

Commit

Permalink
Fix: Do not hide the toolbar when is focused.
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarwrobel committed Jul 2, 2018
1 parent 81ac4e6 commit b1c10cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/toolbar/balloon/balloontoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ export default class BalloonToolbar extends Plugin {
const editor = this.editor;
const selection = editor.model.document.selection;

// Show/hide the toolbar when on editable focus/blur.
this.listenTo( editor.editing.view.document, 'change:isFocused', ( evt, name, isFocused ) => {
if ( !isFocused && this._balloon.visibleView === this.toolbarView ) {
// Show/hide the toolbar on editable focus/blur.
this.listenTo( editor.editing.view.document, 'change:isFocused', ( evt, name, isEditableFocused ) => {
const isToolbarFocused = this.toolbarView.focusTracker.isFocused;
const isToolbarVisible = this._balloon.visibleView === this.toolbarView;

if ( !isEditableFocused && !isToolbarFocused && isToolbarVisible ) {
this.hide();
} else if ( isFocused ) {
} else if ( isEditableFocused ) {
this.show();
}
} );
Expand Down
19 changes: 19 additions & 0 deletions tests/toolbar/balloon/balloontoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,25 @@ describe( 'BalloonToolbar', () => {
stub.restore();
} );

it( 'should not hide on editable blur when #toolbarView gets focus', () => {
editingView.document.isFocused = true;

balloonToolbar.fire( '_selectionChangeDebounced' );

const stub = sandbox.stub( balloon, 'visibleView' ).get( () => balloonToolbar.toolbarView );

sinon.assert.calledOnce( showPanelSpy );
sinon.assert.notCalled( hidePanelSpy );

balloonToolbar.toolbarView.focusTracker.isFocused = true;
editingView.document.isFocused = false;

sinon.assert.calledOnce( showPanelSpy );
sinon.assert.notCalled( hidePanelSpy );

stub.restore();
} );

it( 'should not hide on editable blur when #toolbarView is not visible', () => {
editingView.document.isFocused = true;

Expand Down

0 comments on commit b1c10cf

Please sign in to comment.