Skip to content

Commit 0931be6

Browse files
committed
chore: Use more robust onClickOutside() implementation
1 parent a3f8d58 commit 0931be6

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/components/globalTitleBar.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2025-12-28 15:07:43
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-23 18:16:14
8+
* Last Modified: 2026-03-26 18:41:34
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -117,6 +117,7 @@
117117
import { type TemperatureKelvin } from "~/model/unit";
118118
import { WeatherConditionGroupID, weatherIdToCondition, type WeatherData } from "~/model/weather";
119119
import { getWeatherFromServer } from "~/utils/utils";
120+
import { onClickOutside } from '@vueuse/core'
120121
121122
const i18n = useI18n();
122123
@@ -130,18 +131,17 @@
130131
let weatherAPIErrorMessage = null;
131132
132133
133-
// Global mouse event listener to collapse search input when clicking anywhere while search bar is empty
134+
// Load weather
134135
onMounted(() => {
135-
console.debug("DEBUG - globalTitleBar: Attaching mouse event listener")
136+
getWeather();
137+
});
136138
137-
document.addEventListener("mouseup", () => {
138-
if (globalSearchStr.value === "") {
139-
globalSearchStr.value = null;
140-
}
141-
});
142139
143-
// Load weather
144-
getWeather();
140+
// Collapse search input when clicking anywhere while search bar is empty
141+
onClickOutside(globalSearchInput, () => {
142+
if (globalSearchStr.value === "") {
143+
globalSearchStr.value = null;
144+
}
145145
});
146146
147147

src/components/pickerDialog.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2025-12-24 12:09:18
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-25 21:32:13
8+
* Last Modified: 2026-03-26 18:36:04
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -22,8 +22,7 @@
2222
<!-- Open/Close button -->
2323
<div class="flex flex-col items-center" @keydown.esc="dialogCloseEvent">
2424

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">
2726
<slot name="toggle"></slot>
2827
<!-- WARN: This slot *must not* contain another <button>, it will cause a hydration mismatch! -->
2928
</button>
@@ -36,16 +35,13 @@
3635
Bind position to computed dialogPosition to be able to move container based on distance to screen bounds.
3736
-->
3837
<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>
4138

4239
<!-- Content -->
4340
<dialog
4441
id="picker-dialog"
4542
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"
4643
ref="pickerDialog"
4744
>
48-
4945
<!-- Search and Close button -->
5046
<div class="flex relative justify-end gap-x-4">
5147
<input
@@ -66,8 +62,8 @@
6662
<div ref="pickerDialogItemsDiv" class="max-w-screen overflow-x-auto">
6763
<slot name="items" :searchStr="searchStr"></slot>
6864
</div>
69-
7065
</dialog>
66+
7167
</div>
7268

7369
</div>
@@ -77,6 +73,7 @@
7773

7874
<script setup lang="ts">
7975
import { PhX } from '@phosphor-icons/vue';
76+
import { onClickOutside } from '@vueuse/core'
8077
8178
// Refs
8279
const isOpen: Ref<boolean> = ref(false);
@@ -145,6 +142,9 @@
145142
pickerDialog.value?.close();
146143
}
147144
145+
// Auto-Close dialog when clicking outside
146+
onClickOutside(pickerDialog, () => isOpen.value = false);
147+
148148
149149
// Define Props to be accepted by this component
150150
defineProps({

src/pages/outfits/view.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2025-09-10 17:37:07
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2026-03-26 18:25:07
8+
* Last Modified: 2026-03-26 18:36:39
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -158,10 +158,10 @@
158158
<!-- Title bar when in edit mode, let it clip over the image -->
159159
<div class="flex relative w-full mt-2 -mb-2 justify-end" v-if="editModeEnabled">
160160
<button
161-
class="absolute z-20 custom-button-icon-only"
161+
class="absolute custom-button-icon-only"
162162
@click="removeClothing(thisClothing.id)"
163163
:title="$t('removeItem')"
164-
> <!-- Give this button a higher z-level than the close-popover-dummy to be able to delete clothes while the picker stays open -->
164+
>
165165
<PhX class="size-5 text-red-500"></PhX>
166166
</button>
167167
</div>

0 commit comments

Comments
 (0)