Skip to content

Commit 9037835

Browse files
authored
Merge pull request Expensify#72070 from Expensify/revert-71162-krishna2323/issue/70364
[CP Staging] Revert "fix: Reports - More menu on expense RHP blocks primary and secondary button."
2 parents b2ef70f + 606c568 commit 9037835

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

src/CONST/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ const CONST = {
228228
POPOVER_DROPDOWN_WIDTH: 334,
229229
POPOVER_DROPDOWN_MIN_HEIGHT: 0,
230230
POPOVER_DROPDOWN_MAX_HEIGHT: 416,
231-
POPOVER_MENU_MAX_HEIGHT: 496,
232231
POPOVER_DATE_WIDTH: 338,
233232
POPOVER_DATE_MAX_HEIGHT: 366,
234233
POPOVER_DATE_MIN_HEIGHT: 322,

src/components/MoneyReportHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ function MoneyReportHeader({
12071207
}}
12081208
buttonRef={buttonRef}
12091209
shouldAlwaysShowDropdownMenu
1210-
shouldPopoverUseScrollView={applicableSecondaryActions.length >= 5}
1210+
shouldPopoverUseScrollView={shouldDisplayNarrowVersion && applicableSecondaryActions.length >= 5}
12111211
customText={translate('common.more')}
12121212
options={applicableSecondaryActions}
12131213
isSplitButton={false}

src/components/PopoverMenu.tsx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable react/jsx-props-no-spreading */
2+
import {deepEqual} from 'fast-equals';
23
import type {ReactNode, RefObject} from 'react';
34
import React, {useCallback, useLayoutEffect, useMemo, useState} from 'react';
45
import {StyleSheet, View} from 'react-native';
@@ -171,7 +172,7 @@ const renderWithConditionalWrapper = (shouldUseScrollView: boolean, contentConta
171172
return <ScrollView contentContainerStyle={contentContainerStyle}>{children}</ScrollView>;
172173
}
173174
// eslint-disable-next-line react/jsx-no-useless-fragment
174-
return <View style={contentContainerStyle}>{children}</View>;
175+
return <>{children}</>;
175176
};
176177

177178
function getSelectedItemIndex(menuItems: PopoverMenuItem[]) {
@@ -408,32 +409,14 @@ function BasePopoverMenu({
408409
}, [menuItems, setFocusedIndex]);
409410

410411
const menuContainerStyle = useMemo(() => {
411-
const DEFAULT_MAX_HEIGHT_OFFSET = 250;
412-
const SAFE_BOTTOM_SPACE = variables.h40;
413-
414-
if (!shouldEnableMaxHeight) {
415-
return isSmallScreenWidth ? [] : [styles.createMenuContainer];
416-
}
417-
418412
if (isSmallScreenWidth) {
419-
return [{maxHeight: windowHeight - DEFAULT_MAX_HEIGHT_OFFSET}];
420-
}
421-
422-
const isTopAnchored = anchorAlignment?.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP;
423-
const top = anchorPosition?.vertical;
424-
425-
// Reserve space for footer actions when expanding downward.
426-
if (isTopAnchored && typeof top === 'number') {
427-
const computed = windowHeight - Math.round(top) - SAFE_BOTTOM_SPACE;
428-
const maxHeight = Math.min(CONST.POPOVER_MENU_MAX_HEIGHT, computed);
429-
return [styles.createMenuContainer, {maxHeight}];
413+
return shouldEnableMaxHeight ? {maxHeight: windowHeight - 250} : {};
430414
}
415+
return styles.createMenuContainer;
416+
}, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer]);
431417

432-
// Fallback for other anchor cases
433-
return [styles.createMenuContainer, {maxHeight: windowHeight - DEFAULT_MAX_HEIGHT_OFFSET}];
434-
}, [isSmallScreenWidth, shouldEnableMaxHeight, windowHeight, styles.createMenuContainer, anchorAlignment, anchorPosition]);
418+
const {paddingTop, paddingBottom, paddingVertical, ...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {};
435419

436-
const {...restScrollContainerStyle} = (StyleSheet.flatten([styles.pv4, scrollContainerStyle]) as ViewStyle) ?? {};
437420
return (
438421
<PopoverWithMeasuredContent
439422
anchorPosition={anchorPosition}
@@ -463,12 +446,13 @@ function BasePopoverMenu({
463446
testID={testID}
464447
>
465448
<FocusTrapForModal active={isVisible}>
466-
<View onLayout={onLayout}>
467-
{renderWithConditionalWrapper(
468-
shouldUseScrollView,
469-
[restScrollContainerStyle, menuContainerStyle, containerStyles, {...(isWebOrDesktop ? styles.flex1 : styles.flexGrow1)}],
470-
[renderHeaderText(), enteredSubMenuIndexes.length > 0 && renderBackButtonItem(), renderedMenuItems],
471-
)}
449+
<View
450+
onLayout={onLayout}
451+
style={[menuContainerStyle, containerStyles, {paddingTop, paddingBottom, paddingVertical, ...(isWebOrDesktop ? styles.flex1 : styles.flexGrow1)}]}
452+
>
453+
{renderHeaderText()}
454+
{enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
455+
{renderWithConditionalWrapper(shouldUseScrollView, restScrollContainerStyle, renderedMenuItems)}
472456
</View>
473457
</FocusTrapForModal>
474458
</PopoverWithMeasuredContent>
@@ -477,5 +461,21 @@ function BasePopoverMenu({
477461

478462
PopoverMenu.displayName = 'PopoverMenu';
479463

480-
export default PopoverMenu;
464+
export default React.memo(
465+
PopoverMenu,
466+
(prevProps, nextProps) =>
467+
deepEqual(prevProps.menuItems, nextProps.menuItems) &&
468+
prevProps.isVisible === nextProps.isVisible &&
469+
deepEqual(prevProps.anchorPosition, nextProps.anchorPosition) &&
470+
prevProps.anchorRef === nextProps.anchorRef &&
471+
prevProps.headerText === nextProps.headerText &&
472+
prevProps.fromSidebarMediumScreen === nextProps.fromSidebarMediumScreen &&
473+
deepEqual(prevProps.anchorAlignment, nextProps.anchorAlignment) &&
474+
prevProps.animationIn === nextProps.animationIn &&
475+
prevProps.animationOut === nextProps.animationOut &&
476+
prevProps.animationInTiming === nextProps.animationInTiming &&
477+
prevProps.disableAnimation === nextProps.disableAnimation &&
478+
prevProps.withoutOverlay === nextProps.withoutOverlay &&
479+
prevProps.shouldSetModalVisibility === nextProps.shouldSetModalVisibility,
480+
);
481481
export type {PopoverMenuItem, PopoverMenuProps};

0 commit comments

Comments
 (0)