From 49f9df635561f5de21c8d7318a94355249375bc1 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 4 May 2023 01:20:23 -0500 Subject: [PATCH] [APP-633] Improve some behaviors around desktop leftnav (#581) * Make leftnav elements act as anchor tags (bonus feature in this pr) * Add screen reset behavior to the desktop left nav * Move the leftnav link into the text --- src/view/shell/desktop/LeftNav.tsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index 17d078dc..621c7926 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -86,6 +86,7 @@ interface NavItemProps { const NavItem = observer( ({count, href, icon, iconFilled, label}: NavItemProps) => { const pal = usePalette('default') + const store = useStores() const [pathName] = React.useMemo(() => router.matchPath(href), [href]) const currentRouteName = useNavigationState(state => { if (!state) { @@ -96,12 +97,23 @@ const NavItem = observer( const isCurrent = isTab(currentRouteName, pathName) const {onPress} = useLinkProps({to: href}) + const onPressWrapped = React.useCallback( + (e: React.MouseEvent) => { + e.preventDefault() + if (isCurrent) { + store.emitScreenSoftReset() + } else { + onPress() + } + }, + [onPress, isCurrent, store], + ) return ( @@ -113,7 +125,11 @@ const NavItem = observer( ) : null} - + {label}