From b4a2e4c5643fd5d8d0b41b04b0a1b4a11715138c Mon Sep 17 00:00:00 2001 From: bartosz-lipinski <264380+bartosz-lipinski@users.noreply.github.com> Date: Thu, 19 Nov 2020 12:56:51 -0600 Subject: [PATCH] fix: selected menu --- src/components/DepositAdd/index.tsx | 1 + src/components/Layout/index.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/DepositAdd/index.tsx b/src/components/DepositAdd/index.tsx index 282b45a..78dd45d 100644 --- a/src/components/DepositAdd/index.tsx +++ b/src/components/DepositAdd/index.tsx @@ -75,6 +75,7 @@ export const DepositAdd = (props: { className?: string, reserve: LendingReserve, onChange={(val: any) => { setValue(val); }} + autoFocus={true} style={{ fontSize: 20, boxShadow: "none", diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 2dcb477..7dcf401 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -18,12 +18,15 @@ export const AppLayout = (props: any) => { const location = useLocation(); console.log(location.pathname) - const defaultKey = ({ + const paths: { [key: string]: string } = { '/dashboard': '2', '/deposit': '3', '/borrow': '4' - } as any)[location.pathname] || '1' + }; + + const current = [...Object.keys(paths)].find(key => location.pathname.startsWith(key)) || ''; + const defaultKey = paths[current] || "1"; return (