From d6a7bb80ad2455c6d51f93cd7839cb33450817d5 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 24 Sep 2025 11:44:57 +0530 Subject: [PATCH 1/5] fix: Reports - More menu on expense RHP blocks primary and secondary button. Signed-off-by: krishna2323 --- src/components/PopoverMenu.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 6778afb013c2..1b160282afe2 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -412,8 +412,20 @@ function BasePopoverMenu({ if (isSmallScreenWidth) { return shouldEnableMaxHeight ? {maxHeight: windowHeight - 250} : {}; } - return styles.createMenuContainer; - }, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer]); + + const isTopAnchored = anchorAlignment?.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP; + const top = anchorPosition?.vertical; + let desktopMaxHeightStyle = {}; + if (shouldEnableMaxHeight) { + if (isTopAnchored && typeof top === 'number') { + desktopMaxHeightStyle = {maxHeight: windowHeight - Math.round(top) - 20}; + } else { + desktopMaxHeightStyle = {maxHeight: windowHeight - 250}; + } + } + + return {...styles.createMenuContainer, ...desktopMaxHeightStyle}; + }, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer, anchorAlignment, anchorPosition]); const {paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {}; From c9d5d26468cd3b6142681366e28095ae8fa64669 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 26 Sep 2025 05:57:25 +0530 Subject: [PATCH 2/5] refactor menuContainerStyle calculation. Signed-off-by: krishna2323 --- src/components/PopoverMenu.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 1b160282afe2..78b19c456980 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -409,22 +409,29 @@ function BasePopoverMenu({ }, [menuItems, setFocusedIndex]); const menuContainerStyle = useMemo(() => { + const DEFAULT_MAX_HEIGHT_OFFSET = 250; + const SAFE_BOTTOM_SPACE = variables.h20; + + if (!shouldEnableMaxHeight) { + return isSmallScreenWidth ? [] : [styles.createMenuContainer]; + } + if (isSmallScreenWidth) { - return shouldEnableMaxHeight ? {maxHeight: windowHeight - 250} : {}; + return [{maxHeight: windowHeight - DEFAULT_MAX_HEIGHT_OFFSET}]; } const isTopAnchored = anchorAlignment?.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP; const top = anchorPosition?.vertical; - let desktopMaxHeightStyle = {}; - if (shouldEnableMaxHeight) { - if (isTopAnchored && typeof top === 'number') { - desktopMaxHeightStyle = {maxHeight: windowHeight - Math.round(top) - 20}; - } else { - desktopMaxHeightStyle = {maxHeight: windowHeight - 250}; - } + + // Reserve space for footer actions when expanding downward. + if (isTopAnchored && typeof top === 'number') { + const computed = windowHeight - Math.round(top) - SAFE_BOTTOM_SPACE; + const maxHeight = Math.max(0, computed); + return [styles.createMenuContainer, {maxHeight}]; } - return {...styles.createMenuContainer, ...desktopMaxHeightStyle}; + // Fallback for other anchor cases + return [styles.createMenuContainer, {maxHeight: windowHeight - DEFAULT_MAX_HEIGHT_OFFSET}]; }, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer, anchorAlignment, anchorPosition]); const {paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {}; From 365771ad203d4ec83b3264675cbf459899148d8c Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 26 Sep 2025 06:05:07 +0530 Subject: [PATCH 3/5] fix popover not scrollable on reports page. Signed-off-by: krishna2323 --- src/components/MoneyReportHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 6826b4dc6f03..19aec5c6fee5 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1165,7 +1165,7 @@ function MoneyReportHeader({ }} buttonRef={buttonRef} shouldAlwaysShowDropdownMenu - shouldPopoverUseScrollView={shouldDisplayNarrowVersion && applicableSecondaryActions.length >= 5} + shouldPopoverUseScrollView={applicableSecondaryActions.length >= 5} customText={translate('common.more')} options={applicableSecondaryActions} isSplitButton={false} From e4ec22d0f4134ca0da6870261a7d88aa29f28d5a Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 1 Oct 2025 11:26:59 +0530 Subject: [PATCH 4/5] fix popover menu layout and max height. Signed-off-by: krishna2323 --- src/CONST/index.ts | 1 + src/components/PopoverMenu.tsx | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 9395b1b2ea43..5de6159b05ca 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -228,6 +228,7 @@ const CONST = { POPOVER_DROPDOWN_WIDTH: 334, POPOVER_DROPDOWN_MIN_HEIGHT: 0, POPOVER_DROPDOWN_MAX_HEIGHT: 416, + POPOVER_MENU_MAX_HEIGHT: 496, POPOVER_DATE_WIDTH: 338, POPOVER_DATE_MAX_HEIGHT: 366, POPOVER_DATE_MIN_HEIGHT: 322, diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 78b19c456980..0ed93df68177 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -172,7 +172,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[]) { @@ -410,7 +410,7 @@ function BasePopoverMenu({ const menuContainerStyle = useMemo(() => { const DEFAULT_MAX_HEIGHT_OFFSET = 250; - const SAFE_BOTTOM_SPACE = variables.h20; + const SAFE_BOTTOM_SPACE = variables.h40; if (!shouldEnableMaxHeight) { return isSmallScreenWidth ? [] : [styles.createMenuContainer]; @@ -426,7 +426,7 @@ function BasePopoverMenu({ // Reserve space for footer actions when expanding downward. if (isTopAnchored && typeof top === 'number') { const computed = windowHeight - Math.round(top) - SAFE_BOTTOM_SPACE; - const maxHeight = Math.max(0, computed); + const maxHeight = Math.min(CONST.POPOVER_MENU_MAX_HEIGHT, computed); return [styles.createMenuContainer, {maxHeight}]; } @@ -434,8 +434,7 @@ function BasePopoverMenu({ return [styles.createMenuContainer, {maxHeight: windowHeight - DEFAULT_MAX_HEIGHT_OFFSET}]; }, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer, anchorAlignment, anchorPosition]); - const {paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {}; - + const {...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {}; return ( - - {renderHeaderText()} - {enteredSubMenuIndexes.length > 0 && renderBackButtonItem()} - {renderWithConditionalWrapper(shouldUseScrollView, restScrollContainerStyle, renderedMenuItems)} + + {renderWithConditionalWrapper( + shouldUseScrollView, + [restScrollContainerStyle, menuContainerStyle, containerStyles, {...(isWebOrDesktop ? styles.flex1 : styles.flexGrow1)}], + [renderHeaderText(), enteredSubMenuIndexes.length > 0 && renderBackButtonItem(), renderedMenuItems], + )} From cba41b1cce5dfa6ba8bd08843fb645627da88ce8 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 6 Oct 2025 16:14:59 +0530 Subject: [PATCH 5/5] remove React.memo from PopoverMenu. Signed-off-by: krishna2323 --- src/components/PopoverMenu.tsx | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 0ed93df68177..8eb78a47a6f6 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -1,5 +1,4 @@ /* eslint-disable react/jsx-props-no-spreading */ -import {deepEqual} from 'fast-equals'; import type {ReactNode, RefObject} from 'react'; import React, {useCallback, useLayoutEffect, useMemo, useState} from 'react'; import {StyleSheet, View} from 'react-native'; @@ -478,21 +477,5 @@ function BasePopoverMenu({ PopoverMenu.displayName = 'PopoverMenu'; -export default React.memo( - PopoverMenu, - (prevProps, nextProps) => - deepEqual(prevProps.menuItems, nextProps.menuItems) && - prevProps.isVisible === nextProps.isVisible && - deepEqual(prevProps.anchorPosition, nextProps.anchorPosition) && - prevProps.anchorRef === nextProps.anchorRef && - prevProps.headerText === nextProps.headerText && - prevProps.fromSidebarMediumScreen === nextProps.fromSidebarMediumScreen && - deepEqual(prevProps.anchorAlignment, nextProps.anchorAlignment) && - prevProps.animationIn === nextProps.animationIn && - prevProps.animationOut === nextProps.animationOut && - prevProps.animationInTiming === nextProps.animationInTiming && - prevProps.disableAnimation === nextProps.disableAnimation && - prevProps.withoutOverlay === nextProps.withoutOverlay && - prevProps.shouldSetModalVisibility === nextProps.shouldSetModalVisibility, -); +export default PopoverMenu; export type {PopoverMenuItem, PopoverMenuProps};