diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 4def5757f10d..8c10b3c1cb4d 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -228,6 +228,8 @@ const CONST = { POPOVER_DROPDOWN_WIDTH: 334, POPOVER_DROPDOWN_MIN_HEIGHT: 0, POPOVER_DROPDOWN_MAX_HEIGHT: 416, + POPOVER_MENU_MAX_HEIGHT: 496, + POPOVER_MENU_MAX_HEIGHT_MOBILE: 432, POPOVER_DATE_WIDTH: 338, POPOVER_DATE_MAX_HEIGHT: 366, POPOVER_DATE_MIN_HEIGHT: 322, diff --git a/src/components/MoneyReportHeaderKYCDropdown.tsx b/src/components/MoneyReportHeaderKYCDropdown.tsx index af6de7b22145..dad738ebc948 100644 --- a/src/components/MoneyReportHeaderKYCDropdown.tsx +++ b/src/components/MoneyReportHeaderKYCDropdown.tsx @@ -67,7 +67,7 @@ function MoneyReportHeaderKYCDropdown({ }} buttonRef={buttonRef} shouldAlwaysShowDropdownMenu - shouldPopoverUseScrollView={shouldDisplayNarrowVersion && applicableSecondaryActions.length >= 5} + shouldPopoverUseScrollView={applicableSecondaryActions.length >= 5} customText={translate('common.more')} options={applicableSecondaryActions} isSplitButton={false} diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 8e5c913022e4..a3644c0299cc 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -12,7 +12,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import {isSafari} from '@libs/Browser'; import getPlatform from '@libs/getPlatform'; import variables from '@styles/variables'; @@ -172,7 +171,7 @@ const renderWithConditionalWrapper = (shouldUseScrollView: boolean, contentConta return {children}; } // eslint-disable-next-line react/jsx-no-useless-fragment - return <>{children}; + return {children}; }; function getSelectedItemIndex(menuItems: PopoverMenuItem[]) { @@ -291,7 +290,6 @@ function BasePopoverMenu({ const [currentMenuItems, setCurrentMenuItems] = useState(menuItems); const currentMenuItemsFocusedIndex = getSelectedItemIndex(currentMenuItems); const [enteredSubMenuIndexes, setEnteredSubMenuIndexes] = useState(CONST.EMPTY_ARRAY); - const {windowHeight} = useWindowDimensions(); const platform = getPlatform(); const isWebOrDesktop = platform === CONST.PLATFORM.WEB || platform === CONST.PLATFORM.DESKTOP; const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({initialFocusedIndex: currentMenuItemsFocusedIndex, maxIndex: currentMenuItems.length - 1, isActive: isVisible}); @@ -491,12 +489,25 @@ function BasePopoverMenu({ const menuContainerStyle = useMemo(() => { if (isSmallScreenWidth) { - return shouldEnableMaxHeight ? {maxHeight: windowHeight - 250} : {}; + return shouldEnableMaxHeight ? [{maxHeight: CONST.POPOVER_MENU_MAX_HEIGHT_MOBILE}] : []; } - return styles.createMenuContainer; - }, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer]); + + const stylesArray: ViewStyle[] = [StyleSheet.flatten(styles.createMenuContainer)]; + + if (shouldUseScrollView && shouldEnableMaxHeight) { + stylesArray.push({maxHeight: CONST.POPOVER_MENU_MAX_HEIGHT}); + } + + return stylesArray; + }, [isSmallScreenWidth, shouldEnableMaxHeight, styles.createMenuContainer, shouldUseScrollView]); const {paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {}; + const { + paddingVertical: menuContainerPaddingVertical, + paddingTop: menuContainerPaddingTop, + paddingBottom: menuContainerPaddingBottom, + ...restMenuContainerStyle + } = StyleSheet.flatten(menuContainerStyle) ?? {}; return ( - {renderHeaderText()} - {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()} - {renderWithConditionalWrapper(shouldUseScrollView, restScrollContainerStyle, renderedMenuItems)} + {renderWithConditionalWrapper( + shouldUseScrollView, + [ + { + paddingTop: menuContainerPaddingTop ?? paddingTop, + paddingBottom: menuContainerPaddingBottom ?? paddingBottom, + paddingVertical: paddingVertical ?? menuContainerPaddingVertical ?? 0, + }, + restScrollContainerStyle, + ], + [renderHeaderText(), enteredSubMenuIndexes.length > 0 && renderBackButtonItem(), renderedMenuItems], + )}