Skip to content

Commit

Permalink
fix: change search route when search module is change
Browse files Browse the repository at this point in the history
  • Loading branch information
geeky-abhishek committed May 9, 2022
1 parent 7202394 commit 9edc83d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/search/module-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AppRoute } from '../../types';
import { useAppStore } from '../store/app';
import { useSearchStore } from './search-store';
import { SEARCH_APP_ID } from '../constants';
import { pushHistory } from '../history/hooks';

const SelectorContainer = styled(Container)<{ open: boolean }>`
border-right: 1px solid ${({ theme }): string => theme.palette.gray4.regular};
Expand All @@ -29,6 +30,7 @@ export const ModuleSelector: FC<{ activeRoute: AppRoute; disabled: boolean }> =
() => modules.find((m) => m.route === module) ?? modules[0],
[module, modules]
);

const [open, setOpen] = useState(false);

const dropdownItems = useMemo(
Expand All @@ -38,7 +40,10 @@ export const ModuleSelector: FC<{ activeRoute: AppRoute; disabled: boolean }> =
label,
icon,
active: id === module,
click: () => updateModule(route)
click: (): void => {
updateModule(route);
pushHistory({ route: SEARCH_APP_ID, path: `/${route}` });
}
})),
[module, modules, updateModule]
);
Expand Down
1 change: 1 addition & 0 deletions src/search/search-app-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const SearchAppView: FC = () => {
)),
[searchViews]
);

return (
<>
{/* <RouteLeavingGuard
Expand Down

0 comments on commit 9edc83d

Please sign in to comment.