Skip to content

Commit

Permalink
Fix route not selecting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
brionmario committed Jan 18, 2021
1 parent 05ee7f4 commit 31f3c96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apps/console/src/views/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ export const AdminView: FunctionComponent<AdminViewPropsInterface> = (
const [ mobileSidePanelVisibility, setMobileSidePanelVisibility ] = useState<boolean>(false);
const [ isMobileViewport, setIsMobileViewport ] = useState<boolean>(false);

/**
* Listen to location changes and set the active route accordingly.
*/
useEffect(() => {

if (isEmpty(filteredRoutes) || !location?.pathname) {
return;
}

setSelectedRoute(CommonRouteUtils.getInitialActiveRoute(location.pathname, filteredRoutes));
}, [ location?.pathname, filteredRoutes ]);

useEffect(() => {
setSelectedRoute(CommonRouteUtils.getInitialActiveRoute(location.pathname, filteredRoutes));

Expand Down
10 changes: 9 additions & 1 deletion apps/console/src/views/developer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,17 @@ export const DeveloperView: FunctionComponent<DeveloperViewPropsInterface> = (
const [ mobileSidePanelVisibility, setMobileSidePanelVisibility ] = useState<boolean>(false);
const [ isMobileViewport, setIsMobileViewport ] = useState<boolean>(false);

/**
* Listen to location changes and set the active route accordingly.
*/
useEffect(() => {

if (isEmpty(filteredRoutes) || !location?.pathname) {
return;
}

setSelectedRoute(CommonRouteUtils.getInitialActiveRoute(location.pathname, filteredRoutes));
}, [ filteredRoutes ]);
}, [ location?.pathname, filteredRoutes ]);

useEffect(() => {

Expand Down

0 comments on commit 31f3c96

Please sign in to comment.