Skip to content

Commit

Permalink
Fixing sidebar query param
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjacob committed Apr 10, 2024
1 parent 3d8cfd6 commit a16c961
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/sidebar-navigation/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a16c961

Please sign in to comment.