From 7e6b64f216d6f7ba7c2e8aaf301c64ca6f98663f Mon Sep 17 00:00:00 2001 From: Miguel C Date: Wed, 26 Feb 2025 09:56:30 -0600 Subject: [PATCH] Fix widget sizing logic in LGraphCanvas and LGraphNode (#609) This fixes an issue with widget heights not coinciding with actual computed heights. oldold newnew --- src/LGraphCanvas.ts | 5 ++++- src/LGraphNode.ts | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 1f8aef151..eb9c3ee89 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -1929,9 +1929,12 @@ export class LGraphCanvas implements ConnectionColorContext { for (const widget of node.widgets) { if (widget.hidden || (widget.advanced && !node.showAdvanced)) continue - let widgetWidth, widgetHeight + let widgetWidth: number, widgetHeight: number if (widget.computeSize) { ([widgetWidth, widgetHeight] = widget.computeSize(node.size[0])) + } else if (widget.computeLayoutSize) { + widgetWidth = widget.width + widgetHeight = widget.computedHeight } else { widgetWidth = widget.width || node.size[0] widgetHeight = LiteGraph.NODE_WIDGET_HEIGHT diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 76e18d758..0e0f041ad 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -1898,9 +1898,10 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { continue } - const h = widget.computeSize - ? widget.computeSize(nodeWidth)[1] - : LiteGraph.NODE_WIDGET_HEIGHT + const h = widget.computedHeight ?? + widget.computeSize?.(nodeWidth)[1] ?? + LiteGraph.NODE_WIDGET_HEIGHT + const w = widget.width || nodeWidth if ( widget.last_y !== undefined &&