1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

fixed tripping inside single sidebar

This commit is contained in:
Fedor Katurov 2022-08-05 20:50:39 +07:00
parent bb2e814cf2
commit 32aaa1e8db
2 changed files with 15 additions and 7 deletions

View file

@ -35,7 +35,7 @@ const ProfileSidebar: VFC<ProfileSidebarProps> = ({
page: !isNil(val) ? tabs[val] : undefined, page: !isNil(val) ? tabs[val] : undefined,
}); });
}, },
[open], [open, onRequestClose],
); );
return ( return (

View file

@ -43,6 +43,16 @@ export const SidebarProvider = <T extends SidebarComponent>({
.join("&"); .join("&");
const url = path + "?sidebar=" + name + (query && `&${query}`); 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, { void router.push(url, url, {
shallow: true, shallow: true,
scroll: false, scroll: false,
@ -54,12 +64,10 @@ export const SidebarProvider = <T extends SidebarComponent>({
const close = useCallback(() => { const close = useCallback(() => {
const [path] = router.asPath.split("?"); const [path] = router.asPath.split("?");
// void router.replace(path, path, { void router.replace(path, path, {
// shallow: true, shallow: true,
// scroll: false, scroll: false,
// }); });
router.back();
}, [router]); }, [router]);
const value = useMemo<ContextValue>( const value = useMemo<ContextValue>(