From cfb46f2775e029e011ccc9364b932db313db0933 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 11 Jul 2023 19:44:00 -0700 Subject: [PATCH] fix popup menu --- .../src/components/MkPostFormAttaches.vue | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/packages/client/src/components/MkPostFormAttaches.vue b/packages/client/src/components/MkPostFormAttaches.vue index 7224122a0b..6da744ccfd 100644 --- a/packages/client/src/components/MkPostFormAttaches.vue +++ b/packages/client/src/components/MkPostFormAttaches.vue @@ -54,8 +54,6 @@ const emits = defineEmits([ "changeName", ]); -let menu = ref | null>(null); - const _files = computed({ get: () => props.files, set: (value) => emits("updated", value), @@ -121,46 +119,45 @@ async function describe(file) { } function showFileMenu(file, ev: MouseEvent) { - if (menu) return; - menu = os - .popupMenu( - [ - { - text: i18n.ts.renameFile, - icon: "ph-cursor-text ph-bold ph-lg", - action: () => { - rename(file); - }, + os.popupMenu( + [ + { + text: i18n.ts.renameFile, + icon: "ph-cursor-text ph-bold ph-lg", + action: () => { + rename(file); }, - { - text: file.isSensitive - ? i18n.ts.unmarkAsSensitive - : i18n.ts.markAsSensitive, - icon: file.isSensitive - ? "ph-eye ph-bold ph-lg" - : "ph-eye-slash ph-bold ph-lg", - action: () => { - toggleSensitive(file); - }, + }, + { + text: file.isSensitive + ? i18n.ts.unmarkAsSensitive + : i18n.ts.markAsSensitive, + icon: file.isSensitive + ? "ph-eye ph-bold ph-lg" + : "ph-eye-slash ph-bold ph-lg", + action: () => { + toggleSensitive(file); }, - { - text: i18n.ts.describeFile, - icon: "ph-subtitles ph-bold ph-lg", - action: () => { - describe(file); - }, + }, + { + text: i18n.ts.describeFile, + icon: "ph-subtitles ph-bold ph-lg", + action: () => { + describe(file); }, - { - text: i18n.ts.attachCancel, - icon: "ph-x ph-bold ph-lg", - action: () => { - detachMedia(file.id); - }, + }, + { + text: i18n.ts.attachCancel, + icon: "ph-x ph-bold ph-lg", + action: () => { + detachMedia(file.id); }, - ], - ev.currentTarget ?? ev.target, - ) - .then(() => (menu = null)); + }, + ], + (ev.currentTarget ?? ev.target ?? undefined) as + | HTMLElement + | undefined, + ); }