diff --git a/src/Navigation.tsx b/src/Navigation.tsx index c9f9272194..c1b28f9ac8 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -26,7 +26,7 @@ import {BottomBar} from './view/shell/bottom-bar/BottomBar' import {buildStateObject} from 'lib/routes/helpers' import {State, RouteParams} from 'lib/routes/types' import {colors} from 'lib/styles' -import {isNative} from 'platform/detection' +import {isNative, isWeb} from 'platform/detection' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {router} from './routes' import {usePalette} from 'lib/hooks/usePalette' @@ -385,6 +385,9 @@ function MyProfileTabNavigator() { ) } +const webScrollPositions = new Map() +let webFocusedScreen = null + /** * The FlatNavigator is used by Web to represent the routes * in a single ("flat") stack. @@ -396,6 +399,20 @@ const FlatNavigator = () => { const title = (page: string) => bskyTitle(page, numUnread) return ( ) { onReady={() => { logModuleInitTime() onReady() + + if (isWeb) { + history.scrollRestoration = 'manual' + // TODO: Clean up? + navigationRef.current?.addListener('__unsafe_action__', e => { + if (webFocusedScreen) { + webScrollPositions.set(webFocusedScreen, window.scrollY) + } + }) + } }}> {children}