File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,22 @@ const MenuExample = ({ navigation }: Props) => {
146146 </ TouchableRipple >
147147 </ List . Section >
148148 </ View >
149+ < View style = { styles . alignCenter } >
150+ < Menu
151+ visible = { _getVisible ( 'menu5' ) }
152+ onDismiss = { _toggleMenu ( 'menu5' ) }
153+ anchorPosition = "bottom"
154+ anchor = {
155+ < Button mode = "outlined" onPress = { _toggleMenu ( 'menu5' ) } >
156+ Menu with anchor position
157+ </ Button >
158+ }
159+ >
160+ < Menu . Item onPress = { ( ) => { } } title = "Item 1" />
161+ < Menu . Item onPress = { ( ) => { } } title = "Item 2" />
162+ < Menu . Item onPress = { ( ) => { } } title = "Item 3" />
163+ </ Menu >
164+ </ View >
149165
150166 < View style = { styles . bottomMenu } >
151167 < Menu
Original file line number Diff line number Diff line change @@ -441,12 +441,6 @@ const Menu = ({
441441 updateVisibility ( rendered ) ;
442442 } , [ rendered , updateVisibility ] ) ;
443443
444- React . useEffect ( ( ) => {
445- if ( ! isCoordinate ( anchorRef . current ) && anchorPosition === 'bottom' ) {
446- setTop ( ( prev ) => prev + anchorLayout . height ) ;
447- }
448- } , [ anchorPosition , anchorLayout . height ] ) ;
449-
450444 // I don't know why but on Android measure function is wrong by 24
451445 const additionalVerticalValue = Platform . select ( {
452446 android : statusBarHeight ,
@@ -456,7 +450,10 @@ const Menu = ({
456450 // We need to translate menu while animating scale to imitate transform origin for scale animation
457451 const positionTransforms = [ ] ;
458452 let leftTransformation = left ;
459- let topTransformation = top ;
453+ let topTransformation =
454+ ! isCoordinate ( anchorRef . current ) && anchorPosition === 'bottom'
455+ ? top + anchorLayout . height
456+ : top ;
460457
461458 // Check if menu fits horizontally and if not align it to right.
462459 if ( left <= windowLayout . width - menuLayout . width - SCREEN_INDENT ) {
You can’t perform that action at this time.
0 commit comments