Comfy-Org / Comfy-Org/ComfyUI_frontend
[Bug]: Double-clicking input slots in subgraphs creates primitive nodes in root graph instead of subgraph
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Frontend Version
v1.24.0-0
### Expected Behavior
When double-clicking an input slot inside a subgraph to create a primitive node, the primitive node should be created within the current subgraph context, maintaining the proper graph hierarchy.
### Actual Behavior
Double-clicking an input slot while inside a subgraph creates the primitive node in the root graph instead of the current subgraph. This breaks the encapsulation of subgraphs and creates disconnected nodes in the wrong graph context.
### Steps to Reproduce
1. Create or open a workflow with a subgraph
2. Double-click the subgraph to enter it
3. Add a node with widget inputs inside the subgraph (e.g., a node with a string or number input)
4. Double-click on the input slot of that node to auto-create a primitive node
5. Observe that the primitive node appears to be created and connected
6. Exit the subgraph by clicking the breadcrumb or using navigation
7. Notice that the primitive node was created in the root graph, not inside the subgraph
### Debug Logs
```
[No terminal logs relevant to this frontend issue]
```
### Browser Logs
```
[No console errors - this is a logic issue with graph context]
```
### Setting JSON
```json
[Default settings - issue occurs with clean installation]
```
### What browsers do you use to access the UI?
- Google Chrome
- Mozilla Firefox
### Other Information
The issue appears to be in `src/extensions/core/widgetInputs.ts` at line 596 where the code uses:
```typescript
app.graph.add(node)
```
This always adds to the root graph. When inside a subgraph, it should use the current canvas graph context instead, likely:
```typescript
app.canvas.graph.add(node)
```
This affects the double-click primitive node creation feature documented in the codebase. The feature works correctly in the root graph but fails to respect subgraph boundaries.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-4561-Bug-Double-clicking-input-slots-in-subgraphs-creates-primitive-nodes-in-root-graph--23e6d73d36508145a2daf2f586738e40) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.