Browse Source

Internal: Make visibility functions aware of the fact that plugin could be disabled.

Marek Lewandowski 6 years ago
parent
commit
35fcb082cc
1 changed files with 9 additions and 1 deletions
  1. 9 1
      packages/ckeditor5-widget/src/widgettoolbarrepository.js

+ 9 - 1
packages/ckeditor5-widget/src/widgettoolbarrepository.js

@@ -132,6 +132,10 @@ export default class WidgetToolbarRepository extends Plugin {
 		 */
 		this._balloon = this.editor.plugins.get( 'ContextualBalloon' );
 
+		this.on( 'change:isEnabled', () => {
+			this._updateToolbarsVisibility();
+		} );
+
 		this.listenTo( editor.ui, 'update', () => {
 			this._updateToolbarsVisibility();
 		} );
@@ -222,7 +226,11 @@ export default class WidgetToolbarRepository extends Plugin {
 		for ( const definition of this._toolbarDefinitions.values() ) {
 			const relatedElement = definition.getRelatedElement( this.editor.editing.view.document.selection );
 
-			if ( !this.editor.ui.focusTracker.isFocused ) {
+			if ( !this.isEnabled ) {
+				if ( this._isToolbarInBalloon( definition ) ) {
+					this._hideToolbar( definition );
+				}
+			} else if ( !this.editor.ui.focusTracker.isFocused ) {
 				if ( this._isToolbarVisible( definition ) ) {
 					this._hideToolbar( definition );
 				}