diff --git a/src/composables/painter/usePainter.test.ts b/src/composables/painter/usePainter.test.ts index 80a64fef2d..6146ebf66c 100644 --- a/src/composables/painter/usePainter.test.ts +++ b/src/composables/painter/usePainter.test.ts @@ -359,15 +359,14 @@ describe('usePainter', () => { expect(result).toBe('') }) - it('returns empty string when canvas has no strokes even if modelValue is set', async () => { + it('returns existing modelValue when not dirty (regression: WidgetPainter remount must not blank a workflow-restored mask reference)', async () => { const maskWidget = makeWidget('mask', '') mockWidgets.push(maskWidget) - const { modelValue } = mountPainter() - modelValue.value = 'painter/existing.png [temp]' + mountPainter('test-node', 'painter/existing.png [temp]') const result = await maskWidget.serializeValue!({} as LGraphNode, 0) - expect(result).toBe('') + expect(result).toBe('painter/existing.png [temp]') }) }) diff --git a/src/composables/painter/usePainter.ts b/src/composables/painter/usePainter.ts index 3c60ddfbf7..f0e0b0932a 100644 --- a/src/composables/painter/usePainter.ts +++ b/src/composables/painter/usePainter.ts @@ -624,13 +624,13 @@ export function usePainter(nodeId: string, options: UsePainterOptions) { } async function serializeValue(): Promise { + if (!isDirty.value) return modelValue.value + const el = canvasEl.value - if (!el) return '' + if (!el) return modelValue.value if (isCanvasEmpty()) return '' - if (!isDirty.value) return modelValue.value - const blob = await new Promise((resolve) => el.toBlob(resolve, 'image/png') )