8
0
Просмотр исходного кода

Fix: Fixed a case where image would get a full width just by clicking the resize handle.

Marek Lewandowski 6 лет назад
Родитель
Сommit
7bf1a625dd
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      packages/ckeditor5-widget/src/widgetresize/resizer.js

+ 6 - 3
packages/ckeditor5-widget/src/widgetresize/resizer.js

@@ -157,10 +157,13 @@ export default class Resizer {
 	 * @fires commit
 	 */
 	commit() {
-		const unit = this._options.unit;
-		const newValue = ( unit === '%' ? this.state.proposedWidthPercents : this.state.proposedWidth ) + this._options.unit;
+		if ( this.state.proposedWidth ) {
+			// State might not be initialized (#5195).
+			const unit = this._options.unit;
+			const newValue = ( unit === '%' ? this.state.proposedWidthPercents : this.state.proposedWidth ) + this._options.unit;
 
-		this._options.onCommit( newValue );
+			this._options.onCommit( newValue );
+		}
 
 		this._cleanup();
 	}