diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 16f017ef5..7f16de2e9 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -3493,7 +3493,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { return this.#getMouseOverSlot(slot) === slot } - #isMouseOverWidget(widget: IWidget): boolean { + #isMouseOverWidget(widget: IWidget | undefined): boolean { + if (!widget) return false return this.mouseOver?.overWidget === widget } @@ -3535,19 +3536,20 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { // - the mouse is over the widget // - the slot is valid during link drop // - the slot is connected - const showSlot = isMouseOverSlot || + if ( + isMouseOverSlot || isValidTarget || !slotInstance.isWidgetInputSlot || - this.#isMouseOverWidget(this.getWidgetFromSlot(slotInstance)!) || + this.#isMouseOverWidget(this.getWidgetFromSlot(slotInstance)) || slotInstance.isConnected() - - ctx.globalAlpha = showSlot ? (isValid ? editorAlpha : 0.4 * editorAlpha) : 0 - - slotInstance.draw(ctx, { - colorContext, - lowQuality, - highlight, - }) + ) { + ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha + slotInstance.draw(ctx, { + colorContext, + lowQuality, + highlight, + }) + } } } diff --git a/src/NodeSlot.ts b/src/NodeSlot.ts index c766b7f74..8e8750618 100644 --- a/src/NodeSlot.ts +++ b/src/NodeSlot.ts @@ -72,11 +72,11 @@ export function toNodeSlotClass(slot: INodeInputSlot | INodeOutputSlot): NodeInp } /** - * Whether this slot is an input slot and attached to a widget. + * Type guard: Whether this input slot is attached to a widget. * @param slot The slot to check. */ export function isWidgetInputSlot(slot: INodeInputSlot): slot is IWidgetInputSlot { - return isINodeInputSlot(slot) && !!slot.widget + return !!slot.widget } export abstract class NodeSlot implements INodeSlot {