mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
Further subgraph improvements (#6466)
- Prune disconnected widgets on config panel open - Fix breakage of DOMWidgets on double nest - Fix self clipping of proxied DOMWidget nodes - Blacklist cloning of promtoed widget prop ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6466-Further-subgraph-improvements-29c6d73d365081c8b63dda068486805c) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -143,8 +143,8 @@ onMounted(() => {
|
|||||||
widget.options.selectOn ?? ['focus', 'click'],
|
widget.options.selectOn ?? ['focus', 'click'],
|
||||||
() => {
|
() => {
|
||||||
const lgCanvas = canvasStore.canvas
|
const lgCanvas = canvasStore.canvas
|
||||||
lgCanvas?.selectNode(widget.node)
|
lgCanvas?.selectNode(widgetState.widget.node)
|
||||||
lgCanvas?.bringToFront(widget.node)
|
lgCanvas?.bringToFront(widgetState.widget.node)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
matchesPropertyItem,
|
matchesPropertyItem,
|
||||||
matchesWidgetItem,
|
matchesWidgetItem,
|
||||||
promoteWidget,
|
promoteWidget,
|
||||||
|
pruneDisconnected,
|
||||||
widgetItemToProperty
|
widgetItemToProperty
|
||||||
} from '@/core/graph/subgraph/proxyWidgetUtils'
|
} from '@/core/graph/subgraph/proxyWidgetUtils'
|
||||||
import type { WidgetItem } from '@/core/graph/subgraph/proxyWidgetUtils'
|
import type { WidgetItem } from '@/core/graph/subgraph/proxyWidgetUtils'
|
||||||
@@ -235,6 +236,7 @@ watchDebounced(
|
|||||||
)
|
)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setDraggableState()
|
setDraggableState()
|
||||||
|
if (activeNode.value) pruneDisconnected(activeNode.value)
|
||||||
})
|
})
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
draggableList.value?.dispose()
|
draggableList.value?.dispose()
|
||||||
|
|||||||
@@ -48,9 +48,12 @@ type Overlay = Partial<IBaseWidget> & {
|
|||||||
* on the linked widget
|
* on the linked widget
|
||||||
*/
|
*/
|
||||||
type ProxyWidget = IBaseWidget & { _overlay: Overlay }
|
type ProxyWidget = IBaseWidget & { _overlay: Overlay }
|
||||||
function isProxyWidget(w: IBaseWidget): w is ProxyWidget {
|
export function isProxyWidget(w: IBaseWidget): w is ProxyWidget {
|
||||||
return (w as { _overlay?: Overlay })?._overlay?.isProxyWidget ?? false
|
return (w as { _overlay?: Overlay })?._overlay?.isProxyWidget ?? false
|
||||||
}
|
}
|
||||||
|
export function isDisconnectedWidget(w: ProxyWidget) {
|
||||||
|
return w instanceof disconnectedWidget.constructor
|
||||||
|
}
|
||||||
|
|
||||||
export function registerProxyWidgets(canvas: LGraphCanvas) {
|
export function registerProxyWidgets(canvas: LGraphCanvas) {
|
||||||
//NOTE: canvasStore hasn't been initialized yet
|
//NOTE: canvasStore hasn't been initialized yet
|
||||||
@@ -167,7 +170,7 @@ function resolveLinkedWidget(
|
|||||||
if (!n) return [undefined, undefined]
|
if (!n) return [undefined, undefined]
|
||||||
const widget = n.widgets?.find((w: IBaseWidget) => w.name === widgetName)
|
const widget = n.widgets?.find((w: IBaseWidget) => w.name === widgetName)
|
||||||
//Slightly hacky. Force recursive resolution of nested widgets
|
//Slightly hacky. Force recursive resolution of nested widgets
|
||||||
if (widget instanceof disconnectedWidget.constructor && isProxyWidget(widget))
|
if (widget && isProxyWidget(widget) && isDisconnectedWidget(widget))
|
||||||
widget.computedHeight = 20
|
widget.computedHeight = 20
|
||||||
return [n, widget]
|
return [n, widget]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { parseProxyWidgets } from '@/core/schemas/proxyWidget'
|
import { parseProxyWidgets } from '@/core/schemas/proxyWidget'
|
||||||
import type { ProxyWidgetsProperty } from '@/core/schemas/proxyWidget'
|
import type { ProxyWidgetsProperty } from '@/core/schemas/proxyWidget'
|
||||||
|
import {
|
||||||
|
isProxyWidget,
|
||||||
|
isDisconnectedWidget
|
||||||
|
} from '@/core/graph/subgraph/proxyWidget'
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import type {
|
import type {
|
||||||
IContextMenuValue,
|
IContextMenuValue,
|
||||||
@@ -163,3 +167,10 @@ export function promoteRecommendedWidgets(subgraphNode: SubgraphNode) {
|
|||||||
subgraphNode.properties.proxyWidgets = proxyWidgets
|
subgraphNode.properties.proxyWidgets = proxyWidgets
|
||||||
subgraphNode.computeSize(subgraphNode.size)
|
subgraphNode.computeSize(subgraphNode.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pruneDisconnected(subgraphNode: SubgraphNode) {
|
||||||
|
subgraphNode.properties.proxyWidgets = subgraphNode.widgets
|
||||||
|
.filter(isProxyWidget)
|
||||||
|
.filter((w) => !isDisconnectedWidget(w))
|
||||||
|
.map((w) => [w._overlay.nodeId, w._overlay.widgetName])
|
||||||
|
}
|
||||||
|
|||||||
@@ -546,6 +546,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
|
|||||||
|
|
||||||
// Clean up all promoted widgets
|
// Clean up all promoted widgets
|
||||||
for (const widget of this.widgets) {
|
for (const widget of this.widgets) {
|
||||||
|
if ('isProxyWidget' in widget && widget.isProxyWidget) continue
|
||||||
this.subgraph.events.dispatch('widget-demoted', {
|
this.subgraph.events.dispatch('widget-demoted', {
|
||||||
widget,
|
widget,
|
||||||
subgraphNode: this
|
subgraphNode: this
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
|
|||||||
displayValue,
|
displayValue,
|
||||||
// @ts-expect-error Prevent naming conflicts with custom nodes.
|
// @ts-expect-error Prevent naming conflicts with custom nodes.
|
||||||
labelBaseline,
|
labelBaseline,
|
||||||
|
promoted,
|
||||||
...safeValues
|
...safeValues
|
||||||
} = widget
|
} = widget
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user