Skip to content

draft: Show widget name when connected, hiding only the value #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

yiqun12
Copy link

@yiqun12 yiqun12 commented Jun 9, 2025

Related to Comfy-Org/ComfyUI_frontend#4025

image

Previously, when a widget was connected to an input link, the entire widget's text (name and value) would disappear. This made it difficult to identify the widget's function at a glance.

This commit modifies the drawing behavior to:

  • Only hide the widget's value when it has an active input connection.
  • Continue to display the widget's name/label.

This improves user experience by providing better visual context for connected widgets.

Refactor:

  • Introduced a \hideValue\ property in \LGraphNode.drawWidgets\ to decouple value visibility from the widget's disabled state.
  • Updated \BaseSteppedWidget\ and \TextWidget\ to render only the \displayName\ when the value is hidden.

yiqun12 added 5 commits June 9, 2025 15:55
Previously, when a widget was connected to an input link, the entire widget's text (name and value) would disappear. This made it difficult to identify the widget's function at a glance.

This commit modifies the drawing behavior to:
- Only hide the widget's value when it has an active input connection.
- Continue to display the widget's name/label.

This improves user experience by providing better visual context for connected widgets.

Refactor:
- Introduced a \hideValue\ property in \LGraphNode.drawWidgets\ to decouple value visibility from the widget's disabled state.
- Updated \BaseSteppedWidget\ and \TextWidget\ to render only the \displayName\ when the value is hidden.
@@ -3411,42 +3411,54 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
return !isHidden
}

// sync number of widgets with the number of widgets in the node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the comment referring to?

// Check if locked: either disabled or has an input connection
const connectedSlot = this.getSlotFromWidget(widget)
widget.computedDisabled = widget.disabled || connectedSlot?.link != null
;(widget as any).hideValue = connectedSlot?.link != null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never use type assertions.

Comment on lines +72 to +81
const { margin } = BaseWidget
const x = margin * 2
const area = new Rectangle(x, this.y, options.width - x - margin, this.height * 0.7)
ctx.fillStyle = this.secondary_text_color
drawTextInArea({
ctx,
text: this.displayName,
area,
align: "left",
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we are repeating this logic twice, can we extract to helper function or class method?

if (widget.computedDisabled) ctx.globalAlpha *= 0.5
const width = widget.width || nodeWidth

const forceHideValue = (widget as any).hideValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never use type assertions. We need to look through the code to understand the classes, interfaces, types, and so on. After that, we should implement a solution that naturally extends the current system. If we do this successfuly, we may find that we never need to use type assertions.

To do this properly, it may require approaching the problem by doing research and asking LLM to explain the architecture and objects/classes in the codebase first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure ty for the advice.

@yiqun12 yiqun12 marked this pull request as draft June 10, 2025 19:24
@yiqun12 yiqun12 changed the title feat(widgets): Show widget name when connected, hiding only the value draft: Show widget name when connected, hiding only the value Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants