fix: node hover previews overlapping with sidebar (#6232)

Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/6130 -- node
previews are not positioned in correct location after
https://github.com/Comfy-Org/ComfyUI_frontend/pull/5980

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6232-fix-node-hover-previews-overlapping-with-sidebar-2956d73d365081b2a470f7fb399fda99)
by [Unito](https://www.unito.io)

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Christian Byrne
2025-10-23 13:11:08 -07:00
committed by GitHub
parent 4e5eba6c54
commit 56a6ad5660

View File

@@ -59,7 +59,7 @@
<teleport v-if="isHovered" to="#node-library-node-preview-container">
<div class="node-lib-node-preview" :style="nodePreviewStyle">
<NodePreview ref="previewRef" :node-def="nodeDef" />
<NodePreview :node-def="nodeDef" />
</div>
</teleport>
</div>
@@ -132,11 +132,12 @@ function deleteBlueprint() {
void useSubgraphStore().deleteBlueprint(props.node.data.name)
}
const previewRef = ref<InstanceType<typeof NodePreview> | null>(null)
const nodePreviewStyle = ref<CSSProperties>({
position: 'absolute',
position: 'fixed',
top: '0px',
left: '0px'
left: '0px',
pointerEvents: 'none',
zIndex: 1001
})
const handleNodeHover = async () => {
@@ -144,19 +145,15 @@ const handleNodeHover = async () => {
if (!hoverTarget) return
const targetRect = hoverTarget.getBoundingClientRect()
const margin = 40
const previewHeight = previewRef.value?.$el.offsetHeight || 0
const availableSpaceBelow = window.innerHeight - targetRect.bottom
nodePreviewStyle.value.top =
previewHeight > availableSpaceBelow
? `${Math.max(0, targetRect.top - (previewHeight - availableSpaceBelow) - 20)}px`
: `${targetRect.top - 40}px`
if (sidebarLocation.value === 'left') {
nodePreviewStyle.value.left = `${targetRect.right}px`
} else {
nodePreviewStyle.value.left = `${targetRect.left - 400}px`
}
nodePreviewStyle.value.top = `${targetRect.top}px`
nodePreviewStyle.value.left =
sidebarLocation.value === 'left'
? `${targetRect.right + margin}px`
: `${targetRect.left - margin}px`
nodePreviewStyle.value.transform =
sidebarLocation.value === 'right' ? 'translateX(-100%)' : undefined
}
const container = ref<HTMLElement | null>(null)