Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type MenuItemBaseProps = {
descriptionTextStyle?: StyleProp<TextStyle>;

/** The fill color to pass into the icon. */
iconFill?: string;
iconFill?: string | ((isHovered: boolean) => string);

/** Secondary icon to display on the left side of component, right of the icon */
secondaryIcon?: IconAsset;
Expand Down Expand Up @@ -377,6 +377,9 @@ type MenuItemBaseProps = {

/** Report ID for the avatar on the right */
rightIconReportID?: string;

/** Whether the menu item contains nested submenu items. */
hasSubMenuItems?: boolean;
};

type MenuItemProps = (IconProps | AvatarProps | NoIcon) & MenuItemBaseProps;
Expand Down Expand Up @@ -498,6 +501,7 @@ function MenuItem(
shouldTeleportPortalToModalLayer,
copyValue,
plaidUrl,
hasSubMenuItems = false,
}: MenuItemProps,
ref: PressableRef,
) {
Expand Down Expand Up @@ -755,14 +759,17 @@ function MenuItem(
width={iconWidth}
height={iconHeight}
fill={
// eslint-disable-next-line no-nested-ternary
displayInDefaultIconColor
? undefined
: (iconFill ??
StyleUtils.getIconFillColor(
getButtonState(focused || isHovered, pressed, success, disabled, interactive),
true,
isPaneMenu,
))
: typeof iconFill === 'function'
? iconFill(isHovered)
: (iconFill ??
StyleUtils.getIconFillColor(
getButtonState(focused || isHovered, pressed, success, disabled, interactive),
true,
isPaneMenu,
))
}
additionalStyles={additionalIconStyles}
/>
Expand Down Expand Up @@ -936,11 +943,15 @@ function MenuItem(
styles.pointerEventsAuto,
StyleUtils.getMenuItemIconStyle(isCompact),
disabled && !shouldUseDefaultCursorWhenDisabled && styles.cursorDisabled,
hasSubMenuItems && styles.opacitySemiTransparent,
hasSubMenuItems && styles.pl6,
]}
>
<Icon
src={iconRight}
fill={StyleUtils.getIconFillColor(getButtonState(focused || isHovered, pressed, success, disabled, interactive))}
width={hasSubMenuItems ? variables.iconSizeSmall : variables.iconSizeNormal}
height={hasSubMenuItems ? variables.iconSizeSmall : variables.iconSizeNormal}
/>
</View>
)}
Expand Down
5 changes: 4 additions & 1 deletion src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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';
import {close} from '@userActions/Modal';
import CONST from '@src/CONST';
import type {AnchorPosition} from '@src/styles';
Expand Down Expand Up @@ -290,8 +291,9 @@ function BasePopoverMenu({
<MenuItem
key={previouslySelectedItem?.text}
icon={Expensicons.BackArrow}
iconFill={theme.icon}
iconFill={(isHovered) => (isHovered ? theme.iconHovered : theme.icon)}
style={hasBackButtonText ? styles.pv0 : undefined}
additionalIconStyles={[{width: variables.iconSizeSmall, height: variables.iconSizeSmall}, styles.opacitySemiTransparent, styles.mr1]}
title={hasBackButtonText ? previouslySelectedItem?.backButtonText : previouslySelectedItem?.text}
titleStyle={hasBackButtonText ? styles.createMenuHeaderText : undefined}
shouldShowBasicTitle={hasBackButtonText}
Expand Down Expand Up @@ -340,6 +342,7 @@ function BasePopoverMenu({
titleStyle={StyleSheet.flatten([styles.flex1, item.titleStyle])}
// Spread other props dynamically
{...menuItemProps}
hasSubMenuItems={!!subMenuItems?.length}
shouldShowLoadingSpinnerIcon={shouldShowLoadingSpinnerIcon}
/>
</OfflineWithFeedback>
Expand Down
Loading