From 75b449e6d8751b7dc8e606104ef741ab63a54dc5 Mon Sep 17 00:00:00 2001 From: Joey McKenzie Date: Mon, 10 Mar 2025 12:17:19 -0700 Subject: [PATCH 1/2] fix: use sidebar cookie for state --- app/Http/Middleware/HandleInertiaRequests.php | 1 + bootstrap/app.php | 2 +- resources/js/components/AppShell.vue | 16 ++++------------ resources/js/types/index.d.ts | 1 + 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 204e9280..daa8675b 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -50,6 +50,7 @@ public function share(Request $request): array ...(new Ziggy)->toArray(), 'location' => $request->url(), ], + 'sidebarOpen' => $request->cookie('sidebar_state') === 'true', ]; } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 18d301a4..134581ab 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,7 +14,7 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - $middleware->encryptCookies(except: ['appearance']); + $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); $middleware->web(append: [ HandleAppearance::class, diff --git a/resources/js/components/AppShell.vue b/resources/js/components/AppShell.vue index 5c532032..2022061d 100644 --- a/resources/js/components/AppShell.vue +++ b/resources/js/components/AppShell.vue @@ -1,6 +1,7 @@ diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 853da1d9..8a53a5a4 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -23,6 +23,7 @@ export interface SharedData extends PageProps { quote: { message: string; author: string }; auth: Auth; ziggy: Config & { location: string }; + sidebarOpen: boolean; } export interface User { From c1963e9e23bdf83893f692865868d0f20ca86bd1 Mon Sep 17 00:00:00 2001 From: Joey McKenzie Date: Mon, 10 Mar 2025 14:19:48 -0700 Subject: [PATCH 2/2] chore: rename sidebar cookie --- resources/js/components/ui/sidebar/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/components/ui/sidebar/utils.ts b/resources/js/components/ui/sidebar/utils.ts index c19d1214..5b2e8f9a 100644 --- a/resources/js/components/ui/sidebar/utils.ts +++ b/resources/js/components/ui/sidebar/utils.ts @@ -1,7 +1,7 @@ import { createContext } from 'radix-vue'; import type { ComputedRef, Ref } from 'vue'; -export const SIDEBAR_COOKIE_NAME = 'sidebar:state'; +export const SIDEBAR_COOKIE_NAME = 'sidebar_state'; export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7; export const SIDEBAR_WIDTH = '16rem'; export const SIDEBAR_WIDTH_MOBILE = '18rem';