fix(frontend): MkPopupMenuがドロワーで子メニューの出現と同時にpopupをresolveさせるのをやめさせる

This commit is contained in:
tamaina 2023-08-01 07:32:22 +00:00
parent 8a72a05958
commit 8a6191374c
2 changed files with 17 additions and 5 deletions

View File

@ -82,6 +82,7 @@ const props = defineProps<{
const emit = defineEmits<{
(ev: 'close', actioned?: boolean): void;
(ev: 'hide'): void;
}>();
let itemsEl = $shallowRef<HTMLDivElement>();
@ -166,8 +167,12 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
}
if (props.asDrawer) {
os.popupMenu(children, ev.currentTarget ?? ev.target);
close();
os.popupMenu(children, ev.currentTarget ?? ev.target, {
onClosing: () => {
close();
}
});
emit('hide');
} else {
childTarget = ev.currentTarget ?? ev.target;
childMenu = children;

View File

@ -4,13 +4,13 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkModal ref="modal" v-slot="{ type, maxHeight }" :zPriority="'high'" :src="src" :transparentBg="true" @click="modal.close()" @close="emit('closing')" @closed="emit('closed')">
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :class="{ [$style.drawer]: type === 'drawer' }" @close="modal.close()"/>
<MkModal ref="modal" v-slot="{ type, maxHeight }" :zPriority="'high'" :src="src" :transparentBg="true" @click="close" @close="emit('closing')" @closed="emit('closed')">
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :class="{ [$style.drawer]: type === 'drawer' }" @close="close" @hide="manualShowing = false"/>
</MkModal>
</template>
<script lang="ts" setup>
import { } from 'vue';
import { ref } from 'vue';
import MkModal from './MkModal.vue';
import MkMenu from './MkMenu.vue';
import { MenuItem } from '@/types/menu';
@ -29,6 +29,13 @@ const emit = defineEmits<{
}>();
let modal = $shallowRef<InstanceType<typeof MkModal>>();
const manualShowing = ref(true);
function close() {
if (!modal) return;
manualShowing.value = false;
modal.close();
}
</script>
<style lang="scss" module>