@@ -13,6 +13,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
1313import useStyleUtils from '@hooks/useStyleUtils' ;
1414import useTheme from '@hooks/useTheme' ;
1515import useThemeStyles from '@hooks/useThemeStyles' ;
16+ import useWindowDimensions from '@hooks/useWindowDimensions' ;
1617import { isSafari } from '@libs/Browser' ;
1718import getPlatform from '@libs/getPlatform' ;
1819import variables from '@styles/variables' ;
@@ -22,10 +23,11 @@ import type {AnchorPosition} from '@src/styles';
2223import type { PendingAction } from '@src/types/onyx/OnyxCommon' ;
2324import type AnchorAlignment from '@src/types/utils/AnchorAlignment' ;
2425import type IconAsset from '@src/types/utils/IconAsset' ;
26+ import CompactMenuContext from './CompactMenuContext' ;
2527import FocusableMenuItem from './FocusableMenuItem' ;
2628import FocusTrapForModal from './FocusTrap/FocusTrapForModal' ;
27- import type { MenuItemProps } from './MenuItem' ;
2829import MenuItem from './MenuItem' ;
30+ import type { MenuItemProps } from './MenuItem' ;
2931import type ReanimatedModalProps from './Modal/ReanimatedModal/types' ;
3032import type BaseModalProps from './Modal/types' ;
3133import OfflineWithFeedback from './OfflineWithFeedback' ;
@@ -312,6 +314,7 @@ function BasePopoverMenu({
312314 // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct popover styles
313315 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
314316 const { isSmallScreenWidth, isInLandscapeMode} = useResponsiveLayout ( ) ;
317+ const { windowHeight} = useWindowDimensions ( ) ;
315318 const [ currentMenuItems , setCurrentMenuItems ] = useState ( menuItems ) ;
316319 const currentMenuItemsFocusedIndex = getSelectedItemIndex ( currentMenuItems ) ;
317320 const [ enteredSubMenuIndexes , setEnteredSubMenuIndexes ] = useState < readonly number [ ] > ( CONST . EMPTY_ARRAY ) ;
@@ -374,7 +377,10 @@ function BasePopoverMenu({
374377 icon = { expensifyIcons . BackArrow }
375378 iconFill = { ( isHovered ) => ( isHovered ? theme . iconHovered : theme . icon ) }
376379 style = { hasBackButtonText ? styles . pv0 : undefined }
377- additionalIconStyles = { [ { width : variables . iconSizeSmall , height : variables . iconSizeSmall } , styles . opacitySemiTransparent , styles . mr1 ] }
380+ additionalIconStyles = { [ { width : variables . iconSizeNormal , height : variables . iconSizeNormal } , styles . opacitySemiTransparent , styles . mr1 ] }
381+ iconStyles = { [ { width : variables . iconSizeNormal , height : variables . iconSizeNormal } ] }
382+ wrapperStyle = { [ styles . ph5 , styles . pv3 ] }
383+ innerContainerStyle = { styles . alignItemsCenter }
378384 title = { backButtonTitle }
379385 accessibilityLabel = { `${ translate ( 'common.goBack' ) } , ${ backButtonTitle } ` }
380386 titleStyle = { hasBackButtonText ? styles . createMenuHeaderText : undefined }
@@ -547,16 +553,17 @@ function BasePopoverMenu({
547553 return shouldEnableMaxHeight && ! isInLandscapeMode ? [ { maxHeight : CONST . POPOVER_MENU_MAX_HEIGHT_MOBILE } ] : [ ] ;
548554 }
549555
550- const stylesArray : ViewStyle [ ] = [ StyleSheet . flatten ( styles . createMenuContainer ) ] ;
556+ const stylesArray : ViewStyle [ ] = [ StyleSheet . flatten ( styles . createMenuContainer ) , { width : variables . compactPopoverMenuWidth } , styles . pv2 ] ;
551557
552558 if ( shouldUseScrollView && shouldEnableMaxHeight && ! isInLandscapeMode ) {
553- stylesArray . push ( { maxHeight : CONST . POPOVER_MENU_MAX_HEIGHT } ) ;
559+ stylesArray . push ( { maxHeight : Math . max ( windowHeight - variables . compactPopoverMenuVerticalMargin , CONST . POPOVER_MENU_MAX_HEIGHT ) } ) ;
554560 }
555561
556562 return stylesArray ;
557- } , [ isSmallScreenWidth , shouldEnableMaxHeight , styles . createMenuContainer , shouldUseScrollView ] ) ;
563+ } , [ isSmallScreenWidth , shouldEnableMaxHeight , styles . createMenuContainer , styles . pv2 , shouldUseScrollView , windowHeight , isInLandscapeMode ] ) ;
558564
559- const { paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle } = ( StyleSheet . flatten ( [ styles . pv4 , scrollContainerStyle ] ) as ViewStyle ) ?? { } ;
565+ const { paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle } =
566+ ( StyleSheet . flatten ( [ isSmallScreenWidth ? styles . pv4 : styles . pv2 , scrollContainerStyle ] ) as ViewStyle ) ?? { } ;
560567 const {
561568 paddingVertical : menuContainerPaddingVertical ,
562569 paddingTop : menuContainerPaddingTop ,
@@ -624,16 +631,18 @@ function BasePopoverMenu({
624631 active = { isVisible }
625632 shouldReturnFocus = { ! shouldEnableNewFocusManagement }
626633 >
627- < View
628- onLayout = { onLayout }
629- style = { [ restMenuContainerStyle , restContainerStyles , isWeb ? styles . flex1 : styles . flexGrow1 ] }
630- >
631- { renderWithConditionalWrapper (
632- shouldUseScrollView ,
633- [ scrollViewPaddingStyles , restScrollContainerStyle ] ,
634- [ renderHeaderText ( ) , enteredSubMenuIndexes . length > 0 && renderBackButtonItem ( ) , renderedMenuItems ] ,
635- ) }
636- </ View >
634+ < CompactMenuContext . Provider value >
635+ < View
636+ onLayout = { onLayout }
637+ style = { [ restMenuContainerStyle , restContainerStyles , isWeb ? styles . flex1 : styles . flexGrow1 ] }
638+ >
639+ { renderWithConditionalWrapper (
640+ shouldUseScrollView ,
641+ [ scrollViewPaddingStyles , restScrollContainerStyle ] ,
642+ [ renderHeaderText ( ) , enteredSubMenuIndexes . length > 0 && renderBackButtonItem ( ) , renderedMenuItems ] ,
643+ ) }
644+ </ View >
645+ </ CompactMenuContext . Provider >
637646 </ FocusTrapForModal >
638647 </ PopoverWithMeasuredContent >
639648 ) ;
0 commit comments