From 712da967ce4d44f84382c642c439892cab344144 Mon Sep 17 00:00:00 2001 From: Marley Date: Fri, 14 Jul 2023 20:32:41 -0700 Subject: [PATCH] Improve dropdown --- frontend/components/Dropdown.vue | 11 ++++++++--- frontend/pages/medias/index.vue | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/components/Dropdown.vue b/frontend/components/Dropdown.vue index 6e2fd2a..4c832e2 100644 --- a/frontend/components/Dropdown.vue +++ b/frontend/components/Dropdown.vue @@ -7,19 +7,24 @@ const emit = defineEmits<{ select: [item: string | number] }>() -const open = ref(false) +const [open, toggleOpen] = useToggle() const select = function (item) { emit('select', typeof item === 'object' ? item.id : item) + toggleOpen(false) } + +const dropdown = ref(null) +onClickOutside(dropdown, () => toggleOpen(false))