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

Internal: Fixed an issue where default resizing unit might not be properly recognized.

Without this test added in b6755859ff745742a75536c3e02bbdab1bffbcc6 is failing.
Marek Lewandowski 6 лет назад
Родитель
Сommit
4a3e51a770
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      packages/ckeditor5-widget/src/widgetresize/resizer.js

+ 4 - 4
packages/ckeditor5-widget/src/widgetresize/resizer.js

@@ -83,7 +83,7 @@ export default class Resizer {
 		this.on( 'commit', event => {
 			// State might not be initialized yet. In this case, prevent further handling and make sure that the resizer is
 			// cleaned up (#5195).
-			if ( !this.state.proposedWidth ) {
+			if ( !this.state.proposedWidth && !this.state.proposedWidthPercents ) {
 				this._cleanup();
 				event.stop();
 			}
@@ -153,7 +153,7 @@ export default class Resizer {
 		const editingView = this._options.editor.editing.view;
 
 		editingView.change( writer => {
-			const unit = this._options.unit;
+			const unit = this._options.unit || '%';
 			const newWidth = ( unit === '%' ? newSize.widthPercents : newSize.width ) + unit;
 
 			writer.setStyle( 'width', newWidth, this._options.viewElement );
@@ -185,8 +185,8 @@ export default class Resizer {
 	 * @fires commit
 	 */
 	commit() {
-		const unit = this._options.unit;
-		const newValue = ( unit === '%' ? this.state.proposedWidthPercents : this.state.proposedWidth ) + this._options.unit;
+		const unit = this._options.unit || '%';
+		const newValue = ( unit === '%' ? this.state.proposedWidthPercents : this.state.proposedWidth ) + unit;
 
 		this._options.onCommit( newValue );