Skip to content

Commit

Permalink
Merge pull request #4919 from ckeditor/t/4891
Browse files Browse the repository at this point in the history
Prevent inline hardcoding width property using autogrow plugin
  • Loading branch information
sculpt0r authored Oct 7, 2021
2 parents a5f581b + d4fbea1 commit 875b84c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/creators/themedui.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ CKEDITOR.replaceClass = 'ckeditor';
* ```
*
* @param {Number/String} width The new width. It can be an integer denoting a value
* in pixels or a CSS size value with unit.
* in pixels or a CSS size value with unit. When null is passed, the value will not be set.
* @param {Number/String} height The new height. It can be an integer denoting a value
* in pixels or a CSS size value with unit.
* @param {Boolean} [isContentHeight] Indicates that the provided height is to
Expand Down
7 changes: 2 additions & 5 deletions plugins/autogrow/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@
if ( newHeight != currentHeight && lastHeight != newHeight ) {
newHeight = editor.fire( 'autoGrow', { currentHeight: currentHeight, newHeight: newHeight } ).newHeight;

var boxSizingType = editor.container.getComputedStyle( 'box-sizing' ),
isBorderBox = boxSizingType === 'border-box',
width = editor.container.getSize( 'width', isBorderBox );

editor.resize( width, newHeight, true );
// Set width parameter as null, to update only the height of the editor. (#4891)
editor.resize( null, newHeight, true );
lastHeight = newHeight;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/plugins/autogrow/autogrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@

editor.execCommand( 'autogrow' );

wait();
} );
},

// (#4891)
'test autogrow shouldn\'t add inline width property to editor container': function() {
var editor = this.editor,
bot = this.editorBot;

bot.setData( autogrowTools.getTestContent( 10 ), function() {
editor.once( 'afterCommandExec', function() {
resume( function() {
var editorContainerInlineWidth = editor.container.getStyle( 'width' );

assert.areSame( editorContainerInlineWidth, '', 'Editor shouldn\'t have any inline width property' );
} );
} );

editor.execCommand( 'autogrow' );
wait();
} );
}
Expand Down

0 comments on commit 875b84c

Please sign in to comment.