diff --git a/src/containers/sidebars/ProfileSidebar/index.tsx b/src/containers/sidebars/ProfileSidebar/index.tsx index 7d9fa4b1..8056f0b8 100644 --- a/src/containers/sidebars/ProfileSidebar/index.tsx +++ b/src/containers/sidebars/ProfileSidebar/index.tsx @@ -35,7 +35,7 @@ const ProfileSidebar: VFC = ({ page: !isNil(val) ? tabs[val] : undefined, }); }, - [open], + [open, onRequestClose], ); return ( diff --git a/src/utils/providers/SidebarProvider.tsx b/src/utils/providers/SidebarProvider.tsx index 52120a8b..58d229a8 100644 --- a/src/utils/providers/SidebarProvider.tsx +++ b/src/utils/providers/SidebarProvider.tsx @@ -43,6 +43,16 @@ export const SidebarProvider = ({ .join("&"); const url = path + "?sidebar=" + name + (query && `&${query}`); + // don't store history inside the same sidebar + if (router.query?.sidebar === name) { + void router.replace(url, url, { + shallow: true, + scroll: false, + }); + + return; + } + void router.push(url, url, { shallow: true, scroll: false, @@ -54,12 +64,10 @@ export const SidebarProvider = ({ const close = useCallback(() => { const [path] = router.asPath.split("?"); - // void router.replace(path, path, { - // shallow: true, - // scroll: false, - // }); - - router.back(); + void router.replace(path, path, { + shallow: true, + scroll: false, + }); }, [router]); const value = useMemo(