浏览代码

Imporved checking when components inside ContextualToolbar are disabled.

Oskar Wróbel 8 年之前
父节点
当前提交
962bb28212

+ 1 - 1
packages/ckeditor5-ui/src/toolbar/contextual/contextualtoolbar.js

@@ -179,7 +179,7 @@ export default class ContextualToolbar extends Plugin {
 	_show() {
 		// Don not show ContextualToolbar when all components inside are disabled
 		// see https://github.com/ckeditor/ckeditor5-ui/issues/269.
-		if ( Array.from( this.toolbarView.items ).every( item => !item.isEnabled ) ) {
+		if ( Array.from( this.toolbarView.items ).every( item => item.isEnabled !== undefined && !item.isEnabled ) ) {
 			return;
 		}
 

+ 13 - 0
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -227,6 +227,19 @@ describe( 'ContextualToolbar', () => {
 			sinon.assert.notCalled( balloonAddSpy );
 		} );
 
+		it( 'should add #toolbarView to the #_balloon when at least one component inside does not have #isEnabled interface', () => {
+			Array.from( contextualToolbar.toolbarView.items ).forEach( item => {
+				item.isEnabled = false;
+			} );
+
+			delete contextualToolbar.toolbarView.items.get( 0 ).isEnabled;
+
+			setData( editor.document, '<paragraph>b[a]r</paragraph>' );
+
+			contextualToolbar.show();
+			sinon.assert.calledOnce( balloonAddSpy );
+		} );
+
 		describe( 'on #_selectionChangeDebounced event', () => {
 			let showSpy;