mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 14:54:37 +00:00
[refactor] use LGraphNodeProperties for color property tracking - addresses review feedback
Moves color and bgcolor property change tracking to the standard LGraphNodeProperties system instead of manual event firing in setColorOption. This reduces custom code and leverages the existing property instrumentation infrastructure. Co-authored-by: DrJKL <DrJKL@users.noreply.github.com>
This commit is contained in:
@@ -332,9 +332,6 @@ export class LGraphNode
|
||||
|
||||
/** @inheritdoc {@link IColorable.setColorOption} */
|
||||
setColorOption(colorOption: ColorOption | null): void {
|
||||
const oldColor = this.color
|
||||
const oldBgcolor = this.bgcolor
|
||||
|
||||
if (colorOption == null) {
|
||||
delete this.color
|
||||
delete this.bgcolor
|
||||
@@ -342,29 +339,7 @@ export class LGraphNode
|
||||
this.color = colorOption.color
|
||||
this.bgcolor = colorOption.bgcolor
|
||||
}
|
||||
|
||||
// Trigger property change events for Vue node synchronization
|
||||
if (this.graph) {
|
||||
const newColor = this.color // undefined if deleted
|
||||
const newBgcolor = this.bgcolor // undefined if deleted
|
||||
|
||||
if (oldColor !== newColor) {
|
||||
this.graph.trigger('node:property:changed', {
|
||||
nodeId: this.id,
|
||||
property: 'color',
|
||||
oldValue: oldColor,
|
||||
newValue: newColor
|
||||
})
|
||||
}
|
||||
if (oldBgcolor !== newBgcolor) {
|
||||
this.graph.trigger('node:property:changed', {
|
||||
nodeId: this.id,
|
||||
property: 'bgcolor',
|
||||
oldValue: oldBgcolor,
|
||||
newValue: newBgcolor
|
||||
})
|
||||
}
|
||||
}
|
||||
// Property change events are now handled automatically by LGraphNodeProperties instrumentation
|
||||
}
|
||||
|
||||
/** @inheritdoc {@link IColorable.getColorOption} */
|
||||
|
||||
@@ -7,7 +7,9 @@ const DEFAULT_TRACKED_PROPERTIES: string[] = [
|
||||
'title',
|
||||
'flags.collapsed',
|
||||
'flags.pinned',
|
||||
'mode'
|
||||
'mode',
|
||||
'color',
|
||||
'bgcolor'
|
||||
]
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user