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-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 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';
102103import { useAdminforth } from ' @/adminforth' ;
103104import { useRoute , useRouter } from ' vue-router' ;
104105import CallActionWrapper from ' @/components/CallActionWrapper.vue'
105- import { ref , type ComponentPublicInstance , onMounted , onUnmounted } from ' vue' ;
106+ import { ref , nextTick , type ComponentPublicInstance , onMounted , onUnmounted } from ' vue' ;
106107import type { AdminForthActionFront , AdminForthBulkActionFront , AdminForthComponentDeclarationFull } from ' @/types/Common' ;
107108import { Spinner , Button } from ' @/afcl' ;
108109
@@ -112,6 +113,7 @@ const coreStore = useCoreStore();
112113const router = useRouter ();
113114const threeDotsDropdownItemsRefs = ref <Array <ComponentPublicInstance | null >>([]);
114115const showDropdown = ref (false );
116+ const openToRight = ref (true );
115117const actionLoadingStates = ref <Record <string , boolean >>({});
116118const dropdownRef = ref <HTMLElement | null >(null );
117119const 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
195203function handleClickOutside(e : MouseEvent ) {
0 commit comments