Skip to content

Commit

Permalink
Merge pull request #1108 from near/fix/sidebar-query-param-2
Browse files Browse the repository at this point in the history
Fixing sidebar query param
  • Loading branch information
calebjacob authored Apr 10, 2024
2 parents 3d8cfd6 + a16c961 commit d85541c
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 d85541c

Please sign in to comment.