|
5 | 5 | * Created Date: 2025-12-24 12:09:18 |
6 | 6 | * Author: 3urobeat |
7 | 7 | * |
8 | | - * Last Modified: 2026-03-25 21:32:13 |
| 8 | + * Last Modified: 2026-03-26 18:36:04 |
9 | 9 | * Modified By: 3urobeat |
10 | 10 | * |
11 | 11 | * Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat> |
|
22 | 22 | <!-- Open/Close button --> |
23 | 23 | <div class="flex flex-col items-center" @keydown.esc="dialogCloseEvent"> |
24 | 24 |
|
25 | | - <!-- Give this button a higher z-level than the close-popover-dummy to be able to open another picker and close the current one at the same time, saving a click --> <!-- TODO: Does this still work? --> |
26 | | - <button class="h-fit z-20" :title="toggleText" @click="isOpen = !isOpen" ref="pickerDialogToggleBtn"> |
| 25 | + <button class="h-fit" :title="toggleText" @click="isOpen = !isOpen" ref="pickerDialogToggleBtn"> |
27 | 26 | <slot name="toggle"></slot> |
28 | 27 | <!-- WARN: This slot *must not* contain another <button>, it will cause a hydration mismatch! --> |
29 | 28 | </button> |
|
36 | 35 | Bind position to computed dialogPosition to be able to move container based on distance to screen bounds. |
37 | 36 | --> |
38 | 37 | <div v-if="isOpen" class="absolute z-50 mt-6 transition-all" :class="dialogPosition"> |
39 | | - <!-- Dummy filling the entire page to close popout when clicking on anything outside popout --> |
40 | | - <div class="fixed top-0 left-0 min-h-screen min-w-screen opacity-0" @click="isOpen = !isOpen"></div> |
41 | 38 |
|
42 | 39 | <!-- Content --> |
43 | 40 | <dialog |
44 | 41 | id="picker-dialog" |
45 | 42 | class="relative mt-2 max-w-screen flex flex-col p-2 md:p-4 gap-4 rounded-xl shadow-md dark:text-text-dark bg-bg-field-light dark:bg-bg-field-dark" |
46 | 43 | ref="pickerDialog" |
47 | 44 | > |
48 | | - |
49 | 45 | <!-- Search and Close button --> |
50 | 46 | <div class="flex relative justify-end gap-x-4"> |
51 | 47 | <input |
|
66 | 62 | <div ref="pickerDialogItemsDiv" class="max-w-screen overflow-x-auto"> |
67 | 63 | <slot name="items" :searchStr="searchStr"></slot> |
68 | 64 | </div> |
69 | | - |
70 | 65 | </dialog> |
| 66 | + |
71 | 67 | </div> |
72 | 68 |
|
73 | 69 | </div> |
|
77 | 73 |
|
78 | 74 | <script setup lang="ts"> |
79 | 75 | import { PhX } from '@phosphor-icons/vue'; |
| 76 | + import { onClickOutside } from '@vueuse/core' |
80 | 77 |
|
81 | 78 | // Refs |
82 | 79 | const isOpen: Ref<boolean> = ref(false); |
|
145 | 142 | pickerDialog.value?.close(); |
146 | 143 | } |
147 | 144 |
|
| 145 | + // Auto-Close dialog when clicking outside |
| 146 | + onClickOutside(pickerDialog, () => isOpen.value = false); |
| 147 | +
|
148 | 148 |
|
149 | 149 | // Define Props to be accepted by this component |
150 | 150 | defineProps({ |
|
0 commit comments