mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
fix: collapsed nodes getting extra height based on contents (#7490)
Test Workflow: Flux Schnell workflow (from templates) When nodes are collapsed, they are showing additional height. The amount of extra height appears to correlate with the contents of the node. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7490-fix-collapsed-nodes-getting-extra-height-based-on-contents-2ca6d73d365081af8476d16bbd7da3c3) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -297,19 +297,26 @@ const handleContextMenu = (event: MouseEvent) => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Set initial DOM size from layout store, but respect intrinsic content minimum
|
||||
if (size.value && nodeContainerRef.value) {
|
||||
nodeContainerRef.value.style.setProperty(
|
||||
'--node-width',
|
||||
`${size.value.width}px`
|
||||
)
|
||||
nodeContainerRef.value.style.setProperty(
|
||||
'--node-height',
|
||||
`${size.value.height}px`
|
||||
)
|
||||
}
|
||||
initSizeStyles()
|
||||
})
|
||||
|
||||
/**
|
||||
* Set initial DOM size from layout store, but respect intrinsic content minimum.
|
||||
* Important: nodes can mount in a collapsed state, and the collapse watcher won't
|
||||
* run initially. Match the collapsed runtime behavior by writing to the correct
|
||||
* CSS variables on mount.
|
||||
*/
|
||||
function initSizeStyles() {
|
||||
const el = nodeContainerRef.value
|
||||
const { width, height } = size.value
|
||||
if (!el) return
|
||||
|
||||
const suffix = isCollapsed.value ? '-x' : ''
|
||||
|
||||
el.style.setProperty(`--node-width${suffix}`, `${width}px`)
|
||||
el.style.setProperty(`--node-height${suffix}`, `${height}px`)
|
||||
}
|
||||
|
||||
const baseResizeHandleClasses =
|
||||
'absolute h-3 w-3 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40'
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ vi.mock('@/composables/useErrorHandling', () => ({
|
||||
vi.mock('@/renderer/extensions/vueNodes/layout/useNodeLayout', () => ({
|
||||
useNodeLayout: () => ({
|
||||
position: { x: 100, y: 50 },
|
||||
size: { width: 200, height: 100 },
|
||||
size: computed(() => ({ width: 200, height: 100 })),
|
||||
zIndex: 0,
|
||||
startDrag: vi.fn(),
|
||||
handleDrag: vi.fn(),
|
||||
@@ -201,4 +201,32 @@ describe('LGraphNode', () => {
|
||||
|
||||
expect(wrapper.classes()).toContain('outline-node-stroke-executing')
|
||||
})
|
||||
|
||||
it('should initialize height CSS vars for collapsed nodes', () => {
|
||||
const wrapper = mountLGraphNode({
|
||||
nodeData: {
|
||||
...mockNodeData,
|
||||
flags: { collapsed: true }
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.element.style.getPropertyValue('--node-height')).toBe('')
|
||||
expect(wrapper.element.style.getPropertyValue('--node-height-x')).toBe(
|
||||
'100px'
|
||||
)
|
||||
})
|
||||
|
||||
it('should initialize height CSS vars for expanded nodes', () => {
|
||||
const wrapper = mountLGraphNode({
|
||||
nodeData: {
|
||||
...mockNodeData,
|
||||
flags: { collapsed: false }
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.element.style.getPropertyValue('--node-height')).toBe(
|
||||
'100px'
|
||||
)
|
||||
expect(wrapper.element.style.getPropertyValue('--node-height-x')).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user