mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 10:59:53 +00:00
Fix asset selection in litegraph (#8117)
#8074 included some refactoring to the asset dialogue to ensure that it wouldn't pop up multiple times in vue mode But moving the openModal function to be contained in options means that `this` is no longer the widget, but instead the options object. This is fixed by requiring that widget be explicitly passed as a parameter. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8117-Fix-asset-selection-in-litegraph-2eb6d73d36508176b5a3f6d21964be39) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -55,7 +55,7 @@ interface IWidgetKnobOptions extends IWidgetOptions<number[]> {
|
||||
}
|
||||
|
||||
export interface IWidgetAssetOptions extends IWidgetOptions {
|
||||
openModal: () => void
|
||||
openModal: (widget: IBaseWidget) => void
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,6 +53,6 @@ export class AssetWidget
|
||||
|
||||
override onClick() {
|
||||
//Open Modal
|
||||
this.options.openModal()
|
||||
this.options.openModal(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ const createAssetBrowserWidget = (
|
||||
const displayLabel = currentValue ?? t('widgets.selectModel')
|
||||
const assetBrowserDialog = useAssetBrowserDialog()
|
||||
|
||||
async function openModal(this: IBaseWidget) {
|
||||
async function openModal(widget: IBaseWidget) {
|
||||
if (!isAssetWidget(widget)) {
|
||||
throw new Error(`Expected asset widget but received ${widget.type}`)
|
||||
}
|
||||
@@ -129,7 +129,7 @@ const createAssetBrowserWidget = (
|
||||
}
|
||||
|
||||
const oldValue = widget.value
|
||||
this.value = validatedFilename.data
|
||||
widget.value = validatedFilename.data
|
||||
node.onWidgetChanged?.(
|
||||
widget.name,
|
||||
validatedFilename.data,
|
||||
|
||||
Reference in New Issue
Block a user