diff --git a/visual_console_client/src/Item.ts b/visual_console_client/src/Item.ts index 8d8bd08027..bc4c1d2566 100644 --- a/visual_console_client/src/Item.ts +++ b/visual_console_client/src/Item.ts @@ -252,6 +252,29 @@ abstract class VisualConsoleItem { this.removeResizement = addResizementListener( element, (width: Size["width"], height: Size["height"]) => { + // The label it's outside the item's size, so we need + // to get rid of its size to get the real size of the + // item's content. + if (this.props.label && this.props.label.length > 0) { + const { + width: labelWidth, + height: labelHeight + } = this.labelElementRef.getBoundingClientRect(); + + switch (this.props.labelPosition) { + case "up": + case "down": + height -= labelHeight; + if (width < labelWidth) width = labelWidth; + break; + case "left": + case "right": + width -= labelWidth; + if (height < labelHeight) height = labelHeight; + break; + } + } + // Move the DOM element. this.resizeElement(width, height); // Run the save function.