From 6c0335ca977d69e7a7f9e679c6aa87c89064e717 Mon Sep 17 00:00:00 2001 From: NFriedo <69233063+NFriedo@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:20:03 +0100 Subject: [PATCH] fix bug when opening a different autocomplete than the currently opened one --- .../feature/room/RoomMembers/AddMembers.vue | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/modules/feature/room/RoomMembers/AddMembers.vue b/src/modules/feature/room/RoomMembers/AddMembers.vue index 2128bf5019..d3e2ceb1c3 100644 --- a/src/modules/feature/room/RoomMembers/AddMembers.vue +++ b/src/modules/feature/room/RoomMembers/AddMembers.vue @@ -52,7 +52,6 @@ variant="underlined" :items="memberList" :label="t('common.labels.name')" - :no-data-text="t('common.nodata')" @update:menu="onAutocompleteToggle" /> @@ -90,6 +89,7 @@ import { PropType, ref, toRef } from "vue"; import { RoleName, SchoolForExternalInviteResponse } from "@/serverApi/v3"; import { RoomMember } from "@data-room"; import { useFocusTrap } from "@vueuse/integrations/useFocusTrap"; +import { VAutocomplete } from "vuetify/lib/components/index.mjs"; const props = defineProps({ memberList: { @@ -129,16 +129,32 @@ const onAddMembers = () => { emit("close"); }; -const onAutocompleteToggle = (open: boolean) => { - if (open) { +const onClose = () => emit("close"); + +const addMembersContent = ref(); +const { pause, unpause } = useFocusTrap(addMembersContent, { + immediate: true, +}); + +const autoCompleteSchool = ref(); +const autoCompleteRole = ref(); +const autoCompleteUsers = ref(); + +const onAutocompleteToggle = () => { + const autocompleteRefs = [ + autoCompleteSchool, + autoCompleteRole, + autoCompleteUsers, + ]; + + const isAnyAutocompleteOpen = autocompleteRefs.some( + (autocomplete) => autocomplete.value?.menu + ); + + if (isAnyAutocompleteOpen) { pause(); } else { unpause(); } }; - -const onClose = () => emit("close"); - -const addMembersContent = ref(); -const { pause, unpause } = useFocusTrap(addMembersContent, { immediate: true });