Bladeren bron

Add _enableGroupingOnMaxWidthChange() private method

panr 5 jaren geleden
bovenliggende
commit
8f0f0f4254
1 gewijzigde bestanden met toevoegingen van 16 en 0 verwijderingen
  1. 16 0
      packages/ckeditor5-ui/src/toolbar/toolbarview.js

+ 16 - 0
packages/ckeditor5-ui/src/toolbar/toolbarview.js

@@ -571,6 +571,7 @@ class DynamicGrouping {
 		this.viewElement = view.element;
 
 		this._enableGroupingOnResize();
+		this._enableGroupingOnMaxWidthChange( view );
 	}
 
 	/**
@@ -697,6 +698,21 @@ class DynamicGrouping {
 		this._updateGrouping();
 	}
 
+	/**
+	 * Enables the grouping functionality, just like {@link #_enableGroupingOnResize} but the difference is that
+	 * it listens to the {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth} changes.
+	 *
+	 * Note: Right now it works only with {@link module:editor-inline/inlineeditor~InlineEditor} and
+	 * {@link module:editor-balloon/ballooneditor~BalloonEditor}.
+	 *
+	 * @private
+	 */
+	_enableGroupingOnMaxWidthChange( view ) {
+		view.on( 'change:maxWidth', () => {
+			this._updateGrouping();
+		} );
+	}
+
 	/**
 	 * When called, it will remove the last item from {@link #ungroupedItems} and move it back
 	 * to the {@link #groupedItems} collection.