From a16c9612bcdbb5401b3b42cadf2aa95f03a91af3 Mon Sep 17 00:00:00 2001 From: Caleb Jacob Date: Wed, 10 Apr 2024 15:17:11 -0600 Subject: [PATCH] Fixing sidebar query param --- src/components/sidebar-navigation/hooks.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/sidebar-navigation/hooks.ts b/src/components/sidebar-navigation/hooks.ts index 3b039fe64..b3b4f1140 100644 --- a/src/components/sidebar-navigation/hooks.ts +++ b/src/components/sidebar-navigation/hooks.ts @@ -5,19 +5,20 @@ import { sidebarLayoutEnabled as sidebarLayoutFeatureFlagEnabled } from '@/utils export function useSidebarLayoutEnabled() { const router = useRouter(); + const overrideQueryParamEnabled = router.query.sidebar === 'true'; const [sidebarLayoutTestOverrideEnabled, setSidebarLayoutTestOverrideEnabled] = useState(false); const sidebarLayoutEnabled = sidebarLayoutTestOverrideEnabled || sidebarLayoutFeatureFlagEnabled; useEffect(() => { /* - We only evaluate this once on page load so that we keep it enabled until they close + If the override query param is provided, we want to keep the layout enabled until they close their browser tab. */ - setSidebarLayoutTestOverrideEnabled(router.query.sidebar === 'true'); - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + if (overrideQueryParamEnabled) { + setSidebarLayoutTestOverrideEnabled(true); + } + }, [overrideQueryParamEnabled]); /* The sidebarLayoutTestOverrideEnabled logic is only needed for short term testing.