Fix: Toolbox position desync (#6962)

## Summary

Toggle the toolbox position check based on visibility, not just when
selection changes.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6962-Fix-Toolbox-position-desync-2b76d73d3650818da327c7adee6c1098)
by [Unito](https://www.unito.io)
This commit is contained in:
Alexander Brown
2025-11-26 11:43:58 -08:00
committed by GitHub
parent 4b87b1fdc5
commit 96d12330bb

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 }