Skip to content

Commit 990e8c4

Browse files
committed
Update Navbar.vue
1 parent c688735 commit 990e8c4

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

app/components/Navbar.vue

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,25 @@ function handleKeydown(e) {
231231
232232
/* Auto-close mobile menu when resizing to md+ */
233233
function handleResize() {
234-
if (window.innerWidth >= 768) closeAll();
234+
if (typeof window !== 'undefined' && window.innerWidth >= 768) closeAll();
235235
}
236236
237237
onMounted(() => {
238-
document.addEventListener("click", handleClickOutside);
239-
document.addEventListener("keydown", handleKeydown);
240-
window.addEventListener("resize", handleResize);
238+
if (typeof document !== 'undefined') {
239+
document.addEventListener("click", handleClickOutside);
240+
document.addEventListener("keydown", handleKeydown);
241+
}
242+
if (typeof window !== 'undefined') {
243+
window.addEventListener("resize", handleResize);
244+
}
241245
});
242246
onBeforeUnmount(() => {
243-
document.removeEventListener("click", handleClickOutside);
244-
document.removeEventListener("keydown", handleKeydown);
245-
window.removeEventListener("resize", handleResize);
247+
if (typeof document !== 'undefined') {
248+
document.removeEventListener("click", handleClickOutside);
249+
document.removeEventListener("keydown", handleKeydown);
250+
}
251+
if (typeof window !== 'undefined') {
252+
window.removeEventListener("resize", handleResize);
253+
}
246254
});
247255
</script>

0 commit comments

Comments
 (0)