diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index 2df42f887..28adeae84 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -350,7 +350,7 @@ module.exports = { * @private */ initResize(elem) { - const em = this.em; + const { em, canvas } = this; const editor = em ? em.get('Editor') : ''; const config = em ? em.get('Config') : ''; const pfx = config.stylePrefix || ''; @@ -444,7 +444,13 @@ module.exports = { const style = modelToStyle.getStyle(); if (!onlyHeight) { - style[keyWidth] = autoWidth ? 'auto' : `${rect.w}${unitWidth}`; + const padding = 10; + const frameOffset = canvas.getCanvasView().getFrameOffset(); + const width = + rect.w < frameOffset.width - padding + ? rect.w + : frameOffset.width - padding; + style[keyWidth] = autoWidth ? 'auto' : `${width}${unitWidth}`; } if (!onlyWidth) {