@@ -3,7 +3,7 @@ import { environmentSession } from "../../state/session";
33import { workspaceFileRoots , type EnvironmentId } from "@t3tools/contracts" ;
44import { SymbolView } from "../../components/AppSymbol" ;
55import { MaterialScreenContent } from "../../components/MaterialScreenContent" ;
6- import { useCallback , useMemo , useState , type ComponentProps } from "react" ;
6+ import { useCallback , useMemo , useRef , useState , type ComponentProps } from "react" ;
77import { Platform , Pressable , View , type NativeSyntheticEvent } from "react-native" ;
88import {
99 Screen ,
@@ -48,6 +48,9 @@ export function ThreadFileNavigatorPane(props: {
4848 roots . find ( ( entry ) => entry . path === props . cwd ) ;
4949 const cwd = root ?. path ?? props . cwd ;
5050 const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
51+ // The iOS picker remounts with the root-specific file tree.
52+ const folderPickerScrollOffsetRef = useRef ( 0 ) ;
53+ const [ folderPickerInitialScrollOffset , setFolderPickerInitialScrollOffset ] = useState ( 0 ) ;
5154 const { toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout ( ) ;
5255 const { themeAppearance : highlightTheme } = useAppearancePreferences ( ) ;
5356 const theme = useUniwindTheme ( ) ;
@@ -98,7 +101,18 @@ export function ThreadFileNavigatorPane(props: {
98101 ) ;
99102
100103 const folderPicker = (
101- < WorkspaceFolderPicker roots = { roots } selectedId = { root ?. id } onSelect = { setSelectedRootId } />
104+ < WorkspaceFolderPicker
105+ roots = { roots }
106+ selectedId = { root ?. id }
107+ onSelect = { ( rootId ) => {
108+ setFolderPickerInitialScrollOffset ( folderPickerScrollOffsetRef . current ) ;
109+ setSelectedRootId ( rootId ) ;
110+ } }
111+ initialScrollOffset = { folderPickerInitialScrollOffset }
112+ onScrollOffsetChange = { ( offset ) => {
113+ folderPickerScrollOffsetRef . current = offset ;
114+ } }
115+ />
102116 ) ;
103117
104118 const fileTree = (
0 commit comments