fix(ui): close the canvas menu for a tick before reopening it at the pointer
This commit is contained in:
2 files changed
+6
-7
No files matched your search
@@ -264,17 +264,16 @@ watch(anchor, async (node) => {
|
||||
// The right-click menu opens at the pointer, for the step under it or for the
|
||||
// canvas itself.
|
||||
const menu = ref<{ open: boolean; x: number; y: number; step?: StepNodeData }>({ open: false, x: 0, y: 0 });
|
||||
// A right-click while the menu is open closes it first, so it reopens at the
|
||||
// new pointer instead of keeping its old anchor.
|
||||
// The menu closes for a tick before each opening: the outside right-click has
|
||||
// already closed it in this tick, and reopening in the same one would keep
|
||||
// the old anchor.
|
||||
async function openMenu(event: MouseEvent, step?: StepNodeData): Promise<void> {
|
||||
if (!editable.value) return;
|
||||
event.preventDefault();
|
||||
const box = container.value?.getBoundingClientRect();
|
||||
const next = { open: true, x: event.clientX - (box?.left ?? 0), y: event.clientY - (box?.top ?? 0), step };
|
||||
if (menu.value.open) {
|
||||
menu.value = { ...menu.value, open: false };
|
||||
await nextTick();
|
||||
}
|
||||
menu.value = { ...menu.value, open: false };
|
||||
await nextTick();
|
||||
menu.value = next;
|
||||
}
|
||||
function onNodeMenu({ event, node }: NodeMouseEvent): void {
|
||||
|
||||
Reference in new issue
Block a user