mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
Support display_name on frontend (#6922)
The v3 schema allows defining a `display_name` on inputs, but this was previously ignored on the frontend. It is now used to designate a default value for the label of a widget or input. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6922-Support-display_name-on-frontend-2b66d73d365081d992cbea07abc27a0f) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -27,6 +27,7 @@ export const zBaseInputOptions = z
|
|||||||
.object({
|
.object({
|
||||||
default: z.any().optional(),
|
default: z.any().optional(),
|
||||||
defaultInput: z.boolean().optional(),
|
defaultInput: z.boolean().optional(),
|
||||||
|
display_name: z.string().optional(),
|
||||||
forceInput: z.boolean().optional(),
|
forceInput: z.boolean().optional(),
|
||||||
tooltip: z.string().optional(),
|
tooltip: z.string().optional(),
|
||||||
socketless: z.boolean().optional(),
|
socketless: z.boolean().optional(),
|
||||||
|
|||||||
@@ -95,10 +95,11 @@ export const useLitegraphService = () => {
|
|||||||
)
|
)
|
||||||
if (widgetConstructor && !inputSpec.forceInput) return
|
if (widgetConstructor && !inputSpec.forceInput) return
|
||||||
|
|
||||||
node.addInput(inputName, inputSpec.type, {
|
const input = node.addInput(inputName, inputSpec.type, {
|
||||||
shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined,
|
shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined,
|
||||||
localized_name: st(nameKey, inputName)
|
localized_name: st(nameKey, inputName)
|
||||||
})
|
})
|
||||||
|
input.label ??= inputSpec.display_name
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @internal Setup stroke styles for the node under various conditions.
|
* @internal Setup stroke styles for the node under various conditions.
|
||||||
@@ -164,7 +165,10 @@ export const useLitegraphService = () => {
|
|||||||
) ?? {}
|
) ?? {}
|
||||||
|
|
||||||
if (widget) {
|
if (widget) {
|
||||||
widget.label = st(nameKey, widget.label ?? inputName)
|
widget.label = st(
|
||||||
|
nameKey,
|
||||||
|
widget.label ?? widgetInputSpec.display_name ?? inputName
|
||||||
|
)
|
||||||
widget.options ??= {}
|
widget.options ??= {}
|
||||||
Object.assign(widget.options, {
|
Object.assign(widget.options, {
|
||||||
advanced: inputSpec.advanced,
|
advanced: inputSpec.advanced,
|
||||||
|
|||||||
Reference in New Issue
Block a user