mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 22:39:39 +00:00
More forgiving connections in vue (#6565)
The previous link connection code uses [closest](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest) to find a slot. Closest only checks parents, not siblings. Since the sought element has no children, this meant connection to a slot required the mouse be directly over the slot. This is changed by finding the closest (parent) widget or slot, and then querying for the slot. For simplicity, this means introducing an `lg-node-widget` class. As a result, connections can be made by hovering anywhere over a valid widget.  Resolves #6488 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6565-More-forgiving-connections-in-vue-2a16d73d365081e1bf46f5d54ec382d6) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -20,7 +20,9 @@ export const resolveSlotTargetCandidate = (
|
||||
const { state: dragState, setCompatibleForKey } = useSlotLinkDragUIState()
|
||||
if (!(target instanceof HTMLElement)) return null
|
||||
|
||||
const elWithKey = target.closest<HTMLElement>('[data-slot-key]')
|
||||
const elWithKey = target
|
||||
.closest('.lg-slot, .lg-node-widget')
|
||||
?.querySelector<HTMLElement>('[data-slot-key]')
|
||||
const key = elWithKey?.dataset['slotKey']
|
||||
if (!key) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user