mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 23:20:07 +00:00
## Summary This PR fixes #4681 by building upon the foundation laid in PR #1182 (litegraph.js). It prevents incompatible type connections when dragging from a normal node's output to a SubgraphInputNode's occupied slot. Before: https://github.com/user-attachments/assets/03def938-dccc-4b2c-b65b-745abf02a13b After: https://github.com/user-attachments/assets/7a0a2ed4-9ecd-4147-be56-d643d448d4cb ## Background PR #1182 implemented: - `isValidTarget()` method in SubgraphInput/SubgraphOutput classes for validation - Visual feedback during drag (40% opacity for invalid targets) - Validation at the slot level However, there was a missing piece: while the visual feedback correctly showed invalid targets, the actual connection would still be made when dropped. ## Changes This PR extends PR #1182 by adding the missing connection prevention: 1. **Added `canConnectToSubgraphInput()` method** to render link classes: - `MovingOutputLink` - `ToOutputRenderLink` - `FloatingRenderLink` - All methods use the existing `SubgraphInput.isValidTarget()` from PR #1182 2. **Added validation in `LinkConnector.dropOnIoNode()`**: - Checks `canConnectToSubgraphInput()` before allowing the connection - Logs a warning when rejecting invalid connections - Follows the same pattern as regular node connections 3. **Added `isSubgraphInputValidDrop()` method**: - Provides validation for hover states - Ensures consistent validation across the UI