Skip to content

Commit 2f81e5b

Browse files
authored
Fix: Persist Size across Collapsing Vue Nodes (#6726)
## Summary When restoring a collapsed node, return to the uncollapsed size. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6726-Fix-Persist-Size-across-Collapsing-Vue-Nodes-2ae6d73d365081e28628d5640bc35ab3) by [Unito](https://www.unito.io)
1 parent 471ccca commit 2f81e5b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/renderer/extensions/vueNodes/components/LGraphNode.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@
135135
</template>
136136

137137
<script setup lang="ts">
138-
import { whenever } from '@vueuse/core'
139138
import { storeToRefs } from 'pinia'
140-
import { computed, inject, onErrorCaptured, onMounted, ref } from 'vue'
139+
import { computed, inject, onErrorCaptured, onMounted, ref, watch } from 'vue'
141140
import { useI18n } from 'vue-i18n'
142141
143142
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
@@ -373,11 +372,17 @@ const handleResizePointerDown = (direction: ResizeHandleDirection) => {
373372
}
374373
}
375374
376-
whenever(isCollapsed, () => {
375+
watch(isCollapsed, (collapsed) => {
377376
const element = nodeContainerRef.value
378377
if (!element) return
379-
element.style.setProperty('--node-width', '')
380-
element.style.setProperty('--node-height', '')
378+
const [from, to] = collapsed ? ['', '-x'] : ['-x', '']
379+
const currentWidth = element.style.getPropertyValue(`--node-width${from}`)
380+
element.style.setProperty(`--node-width${to}`, currentWidth)
381+
element.style.setProperty(`--node-width${from}`, '')
382+
383+
const currentHeight = element.style.getPropertyValue(`--node-height${from}`)
384+
element.style.setProperty(`--node-height${to}`, currentHeight)
385+
element.style.setProperty(`--node-height${from}`, '')
381386
})
382387
383388
// Check if node has custom content (like image/video outputs)

0 commit comments

Comments
 (0)