Skip to content

Commit

Permalink
fix(frontend): 子メニューの最大長調整が行われていない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Jun 15, 2024
1 parent 34458d7 commit ea58bf7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/frontend/src/components/MkMenu.child.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<div ref="el" :class="$style.root">
<MkMenu :items="items" :align="align" :width="width" :asDrawer="false" @close="onChildClosed"/>
<MkMenu :items="items" :align="align" :width="width" :maxHeight="maxHeight" :asDrawer="false" @close="onChildClosed"/>
</div>
</template>

<script lang="ts" setup>
import { nextTick, onMounted, onUnmounted, shallowRef, watch } from 'vue';
import { nextTick, onMounted, onUnmounted, shallowRef, ref, watch } from 'vue';
import MkMenu from './MkMenu.vue';
import { MenuItem } from '@/types/menu.js';
Expand All @@ -29,6 +29,7 @@ const emit = defineEmits<{
const el = shallowRef<HTMLElement>();
const align = 'left';
const maxHeight = ref<number | undefined>(undefined);
const SCROLLBAR_THICKNESS = 16;
Expand All @@ -40,6 +41,9 @@ function setPosition() {
let left = props.targetElement.offsetWidth;
let top = (parentRect.top - rootRect.top) - 8;
maxHeight.value = window.innerHeight - rootRect.top - SCROLLBAR_THICKNESS;
if (rootRect.left + left + myRect.width >= (window.innerWidth - SCROLLBAR_THICKNESS)) {
left = -myRect.width;
}
Expand Down

0 comments on commit ea58bf7

Please sign in to comment.