fix(mobile-menu): move store to head and use explicit state transitions to prevent re-opening
All checks were successful
Deploy Theme / deploy (push) Successful in 14s

This commit is contained in:
2026-02-19 20:03:51 +01:00
parent c398905f9b
commit 2e224930b5
4 changed files with 23 additions and 37 deletions

View File

@@ -12,7 +12,6 @@
}
}"
:data-theme="theme"
@htmx:before-request.window="$store.mobileMenu.close()"
class="hidden">
<head>
<meta charset="utf-8">
@@ -24,6 +23,20 @@
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script src="https://unpkg.com/htmx.org@2.0.0"></script>
<script>
document.addEventListener('alpine:init', () => {
Alpine.store('mobileMenu', {
open: false,
close() { this.open = false; },
openMenu() { this.open = true; }
});
});
document.addEventListener('htmx:beforeRequest', () => {
if (window.Alpine) Alpine.store('mobileMenu').close();
});
</script>
{{ghost_head}}
</head>
<body class="{{body_class}} font-sans antialiased" hx-boost="true">