Skip to content

Conversation

@yiqun12
Copy link

@yiqun12 yiqun12 commented Jun 10, 2025

Previously, when a widget was connected to an input, both its name and value mismatch, making it hard to understand the widget’s value at a glance. issue #4025 Comfy-Org/ComfyUI_frontend#4025
This commit updates the drawing logic to improve clarity:
Only hides the value when an input is connected
Keeps the widget name/label visible

image

@yiqun12 yiqun12 closed this Jun 10, 2025
@yiqun12 yiqun12 changed the title feat: add widget value hide test [feat]: add widget value hide Jun 10, 2025
@yiqun12 yiqun12 changed the title test [feat]: add widget value hide test [feat]: add widget value hide(draft) Jun 10, 2025
@yiqun12 yiqun12 reopened this Jun 10, 2025
/** Synonym for "low quality". */
showText?: boolean
/** Hides the value of the widget, showing only the label. */
stripValue?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a property of the base class? Or just specific subclasses?

Copy link
Author

Choose a reason for hiding this comment

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

hmm Good point — stripValue really only applies to display-only (UI) widgets, so moving it out of the base type makes sense. I’ll extract a DisplayWidgetOptions interface and apply it where needed.

Copy link
Author

Choose a reason for hiding this comment

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

I did a careful review of the codebase and decided to keep it in the base class since it's easier to extend in the future. Otherwise, we would need to modify each subclass (e.g., NumberWidget, StringWidget, BoolWidget), which would make the code harder to maintain as we add more widget types. The property also fits well with the existing fields already defined in the base class.

Copy link
Author

Choose a reason for hiding this comment

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

Should I update playwright screenshot for comparison?

@yiqun12 yiqun12 marked this pull request as draft June 10, 2025 19:59
@yiqun12 yiqun12 changed the title test [feat]: add widget value hide(draft) [feat]: hide widget value Jun 11, 2025
@yiqun12 yiqun12 changed the title [feat]: hide widget value [feat]: hide widget value when connected Jun 11, 2025
@yiqun12 yiqun12 marked this pull request as ready for review June 11, 2025 16:52
Comment on lines 202 to 214
const { displayName } = this
const x = margin * 2 + leftPadding
const totalWidth = width - x - 2 * margin - rightPadding
const area = new Rectangle(x, y, totalWidth, height * 0.7)

ctx.fillStyle = this.secondary_text_color

if (stripValue) {
// When the value is hidden, only show the name of the widget
drawTextInArea({ ctx, text: displayName, area, align: "left" })
return
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to be moved up here? It seems like we are making the diff largely than it needs to be. Also, we are now destructuring this twice. Third, we are now potentially changing behavior because we are not restoring the context at the end of text draw (ctx.fillStyle = this.secondary_text_color) in the same sequence as before.

Copy link
Author

Choose a reason for hiding this comment

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

Hey Christian, actually the main change here is due to some code style cleanup, which made the diff look bigger than it actually is. The behavior remains unchanged. I also did a small optimization while cleaning it up.

Copy link
Author

@yiqun12 yiqun12 Jun 12, 2025

Choose a reason for hiding this comment

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

I think this code is ready for review.

@yiqun12 yiqun12 requested a review from christian-byrne June 12, 2025 19:26
Copy link
Contributor

@webfiltered webfiltered left a comment

Choose a reason for hiding this comment

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

I am a little confused by this, to be honest. It's got basically the same problem here as we went over in one of the previous PRs: instead of simply setting a property on the widget (or using an existing one), the PR is passing the stripValue param down through nested function calls.

A stripValue property has been declared on the base class, but it is not actually used.

@yiqun12
Copy link
Author

yiqun12 commented Jun 12, 2025

I am a little confused by this, to be honest. It's got basically the same problem here as we went over in one of the previous PRs: instead of simply setting a property on the widget (or using an existing one), the PR is passing the stripValue param down through nested function calls.

A stripValue property has been declared on the base class, but it is not actually used.

Hmm... Ty for clarifying. I think i am getting this. Let me check the solution for not passing flags through many layers of code.

@yiqun12
Copy link
Author

yiqun12 commented Jun 12, 2025

I am a little confused by this, to be honest. It's got basically the same problem here as we went over in one of the previous PRs: instead of simply setting a property on the widget (or using an existing one), the PR is passing the stripValue param down through nested function calls.

A stripValue property has been declared on the base class, but it is not actually used.

Good point, I think I understand what you mean now. I referred to how widget.computedDisabled is used, and added a computedStripValue property on BaseWidget to control this behavior. Indeed, passing stripValue down through multiple function parameters felt clunky.

@yiqun12 yiqun12 marked this pull request as draft June 13, 2025 00:01
@yiqun12 yiqun12 self-assigned this Jun 13, 2025
@yiqun12 yiqun12 marked this pull request as ready for review June 13, 2025 00:37
@yiqun12 yiqun12 requested a review from webfiltered June 13, 2025 00:37
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.

4 participants