@@ -3,11 +3,12 @@ import BottomSheet, {
33 BottomSheetBackdropProps ,
44 BottomSheetScrollView ,
55} from '@gorhom/bottom-sheet' ;
6- import { ReactNode , forwardRef , memo , useImperativeHandle , useMemo , useRef } from 'react' ;
6+ import { useTheme } from '@storybook/react-native-theming' ;
7+ import { forwardRef , memo , ReactNode , useImperativeHandle , useMemo , useRef } from 'react' ;
78import { Keyboard } from 'react-native' ;
89import { useReducedMotion } from 'react-native-reanimated' ;
910import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
10- import { useTheme } from '@storybook/react-native-theming ' ;
11+ import { useSelectedNode } from './SelectedNodeProvider ' ;
1112
1213interface MobileMenuDrawerProps {
1314 children : ReactNode | ReactNode [ ] ;
@@ -34,18 +35,18 @@ export const MobileMenuDrawer = memo(
3435 const reducedMotion = useReducedMotion ( ) ;
3536 const insets = useSafeAreaInsets ( ) ;
3637 const theme = useTheme ( ) ;
37-
3838 const menuBottomSheetRef = useRef < BottomSheet > ( null ) ;
39+ const { scrollToSelectedNode, scrollRef } = useSelectedNode ( ) ;
3940
4041 useImperativeHandle ( ref , ( ) => ( {
4142 setMobileMenuOpen : ( open : boolean ) => {
4243 if ( open ) {
43- // menuBottomSheetRef.current?.present();
4444 menuBottomSheetRef . current ?. snapToIndex ( 1 ) ;
45+
46+ scrollToSelectedNode ( ) ;
4547 } else {
4648 Keyboard . dismiss ( ) ;
4749
48- // menuBottomSheetRef.current?.dismiss();
4950 menuBottomSheetRef . current ?. close ( ) ;
5051 }
5152 } ,
@@ -82,6 +83,7 @@ export const MobileMenuDrawer = memo(
8283 handleIndicatorStyle = { handleIndicatorStyle }
8384 >
8485 < BottomSheetScrollView
86+ ref = { scrollRef }
8587 keyboardShouldPersistTaps = "handled"
8688 contentContainerStyle = { contentContainerStyle }
8789 >
0 commit comments