File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -924,6 +924,12 @@ export class ComfyPage {
924924 return window [ 'app' ] . canvas . ds . convertOffsetToCanvas ( pos )
925925 } , pos )
926926 }
927+
928+ /** Get number of DOM widgets on the canvas. */
929+ async getDOMWidgetCount ( ) {
930+ return await this . page . locator ( '.dom-widget' ) . count ( )
931+ }
932+
927933 async getNodeRefById ( id : NodeId ) {
928934 return new NodeReference ( id , this )
929935 }
Original file line number Diff line number Diff line change @@ -31,4 +31,20 @@ test.describe('DOM Widget', () => {
3131 await comfyPage . nextFrame ( )
3232 await expect ( comfyPage . canvas ) . toHaveScreenshot ( 'focus-mode-on.png' )
3333 } )
34+
35+ // No DOM widget should be created by creation of interim LGraphNode objects.
36+ test ( 'Copy node with DOM widget by dragging + alt' , async ( { comfyPage } ) => {
37+ const initialCount = await comfyPage . getDOMWidgetCount ( )
38+
39+ // TextEncodeNode1
40+ await comfyPage . page . mouse . move ( 618 , 191 )
41+ await comfyPage . page . keyboard . down ( 'Alt' )
42+ await comfyPage . page . mouse . down ( )
43+ await comfyPage . page . mouse . move ( 100 , 100 )
44+ await comfyPage . page . mouse . up ( )
45+ await comfyPage . page . keyboard . up ( 'Alt' )
46+
47+ const finalCount = await comfyPage . getDOMWidgetCount ( )
48+ expect ( finalCount ) . toBe ( initialCount + 1 )
49+ } )
3450} )
Original file line number Diff line number Diff line change @@ -267,6 +267,15 @@ export const addWidget = <W extends BaseDOMWidget<object | string>>(
267267 widget : W
268268) => {
269269 node . addCustomWidget ( widget )
270+
271+ if ( node . graph ) {
272+ useDomWidgetStore ( ) . registerWidget ( widget )
273+ }
274+
275+ node . onAdded = useChainCallback ( node . onAdded , ( ) => {
276+ useDomWidgetStore ( ) . registerWidget ( widget )
277+ } )
278+
270279 node . onRemoved = useChainCallback ( node . onRemoved , ( ) => {
271280 widget . onRemove ?.( )
272281 } )
@@ -275,8 +284,6 @@ export const addWidget = <W extends BaseDOMWidget<object | string>>(
275284 widget . options . beforeResize ?. call ( widget , node )
276285 widget . options . afterResize ?. call ( widget , node )
277286 } )
278-
279- useDomWidgetStore ( ) . registerWidget ( widget )
280287}
281288
282289LGraphNode . prototype . addDOMWidget = function <
You can’t perform that action at this time.
0 commit comments