Skip to content

Commit b6a1f79

Browse files
authored
Merge pull request #734 from devforth/feature/AdminForth/1953/image
fix: raise three dots menu above sidebar AdminForth/1953/image
2 parents a840a27 + 6edf217 commit b6a1f79

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎adminforth/spa/src/components/ThreeDotsMenu.vue‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
:class="{
1818
'block': showDropdown,
1919
'hidden': !showDropdown,
20-
'left-0 md:left-auto': checkboxes && checkboxes.length > 0
20+
'left-0': openToRight,
21+
'right-0': !openToRight
2122
}"
22-
class="absolute z-30 mt-3 bg-lightThreeDotsMenuBodyBackground divide-y divide-gray-100 rounded-lg shadow w-max max-w-64 dark:bg-darkThreeDotsMenuBodyBackground dark:divide-gray-600 right-0">
23+
class="absolute z-50 mt-3 bg-lightThreeDotsMenuBodyBackground divide-y divide-gray-100 rounded-lg shadow w-max max-w-64 dark:bg-darkThreeDotsMenuBodyBackground dark:divide-gray-600">
2324
<ul class="py-2 text-sm text-lightThreeDotsMenuBodyText dark:text-darkThreeDotsMenuBodyText" aria-labelledby="dropdownMenuIconButton">
2425
<li v-for="(item, i) in threeDotsDropdownItems" :key="`dropdown-item-${i}`">
2526
<div
@@ -102,7 +103,7 @@ import { useCoreStore } from '@/stores/core';
102103
import { useAdminforth } from '@/adminforth';
103104
import { useRoute, useRouter } from 'vue-router';
104105
import CallActionWrapper from '@/components/CallActionWrapper.vue'
105-
import { ref, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
106+
import { ref, nextTick, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
106107
import type { AdminForthActionFront, AdminForthBulkActionFront, AdminForthComponentDeclarationFull } from '@/types/Common';
107108
import { Spinner, Button } from '@/afcl';
108109
@@ -112,6 +113,7 @@ const coreStore = useCoreStore();
112113
const router = useRouter();
113114
const threeDotsDropdownItemsRefs = ref<Array<ComponentPublicInstance | null>>([]);
114115
const showDropdown = ref(false);
116+
const openToRight = ref(true);
115117
const actionLoadingStates = ref<Record<string, boolean>>({});
116118
const dropdownRef = ref<HTMLElement | null>(null);
117119
const buttonTriggerRef = ref<ComponentPublicInstance | null>(null);
@@ -188,8 +190,14 @@ async function injectedComponentClick(index: number, event?: MouseEvent) {
188190
showDropdown.value = false;
189191
}
190192
191-
function toggleDropdownVisibility() {
193+
async function toggleDropdownVisibility() {
192194
showDropdown.value = !showDropdown.value;
195+
if (!showDropdown.value) return;
196+
await nextTick();
197+
const triggerRect = (buttonTriggerRef.value!.$el as HTMLElement).getBoundingClientRect();
198+
const appEl = document.getElementById('app')!;
199+
const appContentRight = appEl.getBoundingClientRect().right - parseFloat(getComputedStyle(appEl).paddingRight);
200+
openToRight.value = triggerRect.left + dropdownRef.value!.offsetWidth <= appContentRight;
193201
}
194202
195203
function handleClickOutside(e: MouseEvent) {

0 commit comments

Comments
 (0)