This commit is contained in:
tamaina 2023-08-04 12:56:06 +00:00
parent c73ec73920
commit 1294f5f06f
1 changed files with 11 additions and 10 deletions

View File

@ -4,8 +4,8 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :src="src" :transparentBg="true" @click="click" @close="onModalClose" @closed="closed"> <MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :src="src" :transparentBg="true" @click="click" @close="onModalClose" @closed="onModalClosed">
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :class="{ [$style.drawer]: type === 'drawer' }" @close="onMenuClose" @hide="manualShowing = false"/> <MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :class="{ [$style.drawer]: type === 'drawer' }" @close="onMenuClose" @hide="hide"/>
</MkModal> </MkModal>
</template> </template>
@ -30,6 +30,7 @@ const emit = defineEmits<{
let modal = $shallowRef<InstanceType<typeof MkModal>>(); let modal = $shallowRef<InstanceType<typeof MkModal>>();
const manualShowing = ref(true); const manualShowing = ref(true);
const hiding = ref(false);
function click() { function click() {
close(); close();
@ -41,22 +42,22 @@ function onModalClose() {
function onMenuClose() { function onMenuClose() {
close(); close();
if (manualShowing.value === false) {
// hideclosed
emit('closed');
}
} }
function closed() { function onModalClosed() {
if (manualShowing.value === true) { if (!hiding.value) {
// hideclosed // hideclosed
emit('closed'); emit('closed');
} }
} }
function hide() {
manualShowing.value = false;
hiding.value = true;
}
function close() { function close() {
if (!modal) return; manualShowing.value = false;
modal.close();
} }
</script> </script>