[backport core/1.33] Fix: Toolbox position desync (#7241)

Backport of #6962 to `core/1.33`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7241-backport-core-1-33-Fix-Toolbox-position-desync-2c36d73d3650810bb77bdd720976a119)
by [Unito](https://www.unito.io)

Co-authored-by: Alexander Brown <drjkl@comfy.org>
This commit is contained in:
Comfy Org PR Bot
2025-12-09 08:26:50 +09:00
committed by GitHub
parent 4ae12b8006
commit 0e757b88fa

View File

@@ -1,5 +1,5 @@
import { useElementBounding, useRafFn } from '@vueuse/core'
import { computed, onUnmounted, ref, watch } from 'vue'
import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
import type { Ref } from 'vue'
import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteGraphItems'
@@ -157,6 +157,14 @@ export function useSelectionToolboxPosition(
// Sync with canvas transform
const { resume: startSync, pause: stopSync } = useRafFn(updateTransform)
watchEffect(() => {
if (visible.value) {
startSync()
} else {
stopSync()
}
})
// Watch for selection changes
watch(
() => canvasStore.getCanvas().state.selectionChanged,
@@ -173,11 +181,6 @@ export function useSelectionToolboxPosition(
}
updateSelectionBounds()
canvasStore.getCanvas().state.selectionChanged = false
if (visible.value) {
startSync()
} else {
stopSync()
}
}
},
{ immediate: true }