mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
Directly use node.collapsed state in dom widget (#2900)
This commit is contained in:
@@ -133,9 +133,8 @@ LGraphCanvas.prototype.computeVisibleNodes = function (
|
|||||||
if (w.element) {
|
if (w.element) {
|
||||||
w.element.dataset.isInVisibleNodes = hidden ? 'false' : 'true'
|
w.element.dataset.isInVisibleNodes = hidden ? 'false' : 'true'
|
||||||
const shouldOtherwiseHide = w.element.dataset.shouldHide === 'true'
|
const shouldOtherwiseHide = w.element.dataset.shouldHide === 'true'
|
||||||
const isCollapsed = w.element.dataset.collapsed === 'true'
|
|
||||||
const wasHidden = w.element.hidden
|
const wasHidden = w.element.hidden
|
||||||
const actualHidden = hidden || shouldOtherwiseHide || isCollapsed
|
const actualHidden = hidden || shouldOtherwiseHide || node.collapsed
|
||||||
w.element.hidden = actualHidden
|
w.element.hidden = actualHidden
|
||||||
w.element.style.display = actualHidden ? 'none' : ''
|
w.element.style.display = actualHidden ? 'none' : ''
|
||||||
if (actualHidden && !wasHidden) {
|
if (actualHidden && !wasHidden) {
|
||||||
@@ -252,12 +251,12 @@ export class DOMWidgetImpl<T extends HTMLElement, V extends object | string>
|
|||||||
// @ts-expect-error custom widget type
|
// @ts-expect-error custom widget type
|
||||||
this.type === 'converted-widget' ||
|
this.type === 'converted-widget' ||
|
||||||
// @ts-expect-error custom widget type
|
// @ts-expect-error custom widget type
|
||||||
this.type === 'hidden'
|
this.type === 'hidden' ||
|
||||||
|
node.collapsed
|
||||||
|
|
||||||
this.element.dataset.shouldHide = hidden ? 'true' : 'false'
|
this.element.dataset.shouldHide = hidden ? 'true' : 'false'
|
||||||
const isInVisibleNodes = this.element.dataset.isInVisibleNodes === 'true'
|
const isInVisibleNodes = this.element.dataset.isInVisibleNodes === 'true'
|
||||||
const isCollapsed = this.element.dataset.collapsed === 'true'
|
const actualHidden = hidden || !isInVisibleNodes
|
||||||
const actualHidden = hidden || !isInVisibleNodes || isCollapsed
|
|
||||||
const wasHidden = this.element.hidden
|
const wasHidden = this.element.hidden
|
||||||
this.element.hidden = actualHidden
|
this.element.hidden = actualHidden
|
||||||
this.element.style.display = actualHidden ? 'none' : ''
|
this.element.style.display = actualHidden ? 'none' : ''
|
||||||
@@ -358,25 +357,6 @@ LGraphNode.prototype.addDOMWidget = function <
|
|||||||
this.addCustomWidget(widget)
|
this.addCustomWidget(widget)
|
||||||
elementWidgets.add(this)
|
elementWidgets.add(this)
|
||||||
|
|
||||||
const collapse = this.collapse
|
|
||||||
this.collapse = function (this: LGraphNode, force?: boolean) {
|
|
||||||
collapse.call(this, force)
|
|
||||||
if (this.collapsed) {
|
|
||||||
element.hidden = true
|
|
||||||
element.style.display = 'none'
|
|
||||||
}
|
|
||||||
element.dataset.collapsed = this.collapsed ? 'true' : 'false'
|
|
||||||
}
|
|
||||||
|
|
||||||
const { onConfigure } = this
|
|
||||||
this.onConfigure = function (
|
|
||||||
this: LGraphNode,
|
|
||||||
serializedNode: ISerialisedNode
|
|
||||||
) {
|
|
||||||
onConfigure?.call(this, serializedNode)
|
|
||||||
element.dataset.collapsed = this.collapsed ? 'true' : 'false'
|
|
||||||
}
|
|
||||||
|
|
||||||
const onRemoved = this.onRemoved
|
const onRemoved = this.onRemoved
|
||||||
this.onRemoved = function (this: LGraphNode) {
|
this.onRemoved = function (this: LGraphNode) {
|
||||||
element.remove()
|
element.remove()
|
||||||
|
|||||||
Reference in New Issue
Block a user