Skip to content

Commit 7cbc648

Browse files
committed
fix: correct click area for the injected in three dots menu component
1 parent f2aec6a commit 7cbc648

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

adminforth/spa/src/components/ThreeDotsMenu.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
'pointer-events-none': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
2222
'opacity-50': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
2323
'cursor-not-allowed': checkboxes && checkboxes.length === 0 && item.meta?.disabledWhenNoCheckboxes,
24-
}">
25-
<component :is="getCustomComponent(item)"
24+
}"
25+
@click="injectedComponentClick(i)">
26+
<component :ref="(el: any) => setComponentRef(el, i)" :is="getCustomComponent(item)"
2627
:meta="item.meta"
2728
:resource="coreStore.resource"
2829
:adminUser="coreStore.adminUser"
@@ -75,10 +76,12 @@ import adminforth from '@/adminforth';
7576
import { callAdminForthApi } from '@/utils';
7677
import { useRoute, useRouter } from 'vue-router';
7778
import type { AdminForthComponentDeclarationFull, AdminForthBulkActionCommon, AdminForthActionInput } from '@/types/Common.js';
79+
import { ref, type ComponentPublicInstance } from 'vue';
7880
7981
const route = useRoute();
8082
const coreStore = useCoreStore();
8183
const router = useRouter();
84+
const threeDotsDropdownItemsRefs = ref<Array<ComponentPublicInstance | null>>([]);
8285
8386
const props = defineProps({
8487
threeDotsDropdownItems: Array<AdminForthComponentDeclarationFull>,
@@ -95,6 +98,12 @@ const props = defineProps({
9598
9699
const emit = defineEmits(['startBulkAction']);
97100
101+
function setComponentRef(el: ComponentPublicInstance | null, index: number) {
102+
if (el) {
103+
threeDotsDropdownItemsRefs.value[index] = el;
104+
}
105+
}
106+
98107
async function handleActionClick(action: AdminForthActionInput) {
99108
adminforth.list.closeThreeDotsDropdown();
100109
@@ -151,4 +160,11 @@ function startBulkAction(actionId: string) {
151160
adminforth.list.closeThreeDotsDropdown();
152161
emit('startBulkAction', actionId);
153162
}
163+
164+
async function injectedComponentClick(index: number) {
165+
const componentRef = threeDotsDropdownItemsRefs.value[index];
166+
if (componentRef && 'click' in componentRef) {
167+
(componentRef as any).click?.();
168+
}
169+
}
154170
</script>

0 commit comments

Comments
 (0)