Skip to content

Commit d1d4b9f

Browse files
stitesExpensifyOSBotify
authored and
OSBotify
committed
Merge pull request #5796 from Expensify/marcaaron-preventTappableBankAccount
Prevent tappable bank account in EnableStep (cherry picked from commit 7b82f4d)
1 parent ffaefdc commit d1d4b9f

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

src/components/MenuItem.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'underscore';
12
import React from 'react';
23
import {
34
View, Pressable,
@@ -19,7 +20,7 @@ const propTypes = {
1920
const defaultProps = {
2021
badgeText: undefined,
2122
shouldShowRightIcon: false,
22-
wrapperStyle: {},
23+
wrapperStyle: [],
2324
success: false,
2425
icon: undefined,
2526
iconWidth: undefined,
@@ -32,6 +33,8 @@ const defaultProps = {
3233
disabled: false,
3334
subtitle: undefined,
3435
iconType: 'icon',
36+
onPress: () => {},
37+
interactive: true,
3538
};
3639

3740
const MenuItem = ({
@@ -52,6 +55,7 @@ const MenuItem = ({
5255
disabled,
5356
subtitle,
5457
iconType,
58+
interactive,
5559
}) => (
5660
<Pressable
5761
onPress={(e) => {
@@ -63,8 +67,8 @@ const MenuItem = ({
6367
}}
6468
style={({hovered, pressed}) => ([
6569
styles.popoverMenuItem,
66-
getButtonBackgroundColorStyle(getButtonState(focused || hovered, pressed, success, disabled)),
67-
wrapperStyle,
70+
getButtonBackgroundColorStyle(getButtonState(focused || hovered, pressed, success, disabled, interactive)),
71+
..._.isArray(wrapperStyle) ? wrapperStyle : [wrapperStyle],
6872
])}
6973
disabled={disabled}
7074
>
@@ -83,7 +87,7 @@ const MenuItem = ({
8387
width={iconWidth}
8488
height={iconHeight}
8589
fill={iconFill || getIconFillColor(
86-
getButtonState(focused || hovered, pressed, success, disabled),
90+
getButtonState(focused || hovered, pressed, success, disabled, interactive),
8791
)}
8892
/>
8993
</View>
@@ -106,7 +110,7 @@ const MenuItem = ({
106110
style={[
107111
styles.popoverMenuText,
108112
styles.ml3,
109-
(disabled ? styles.disabledText : undefined),
113+
(interactive && disabled ? styles.disabledText : undefined),
110114
]}
111115
numberOfLines={1}
112116
>
@@ -134,7 +138,7 @@ const MenuItem = ({
134138
<View style={styles.popoverMenuIcon}>
135139
<Icon
136140
src={iconRight}
137-
fill={getIconFillColor(getButtonState(focused || hovered, pressed, success, disabled))}
141+
fill={getIconFillColor(getButtonState(focused || hovered, pressed, success, disabled, interactive))}
138142
/>
139143
</View>
140144
)}

src/components/menuItemPropTypes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import PropTypes from 'prop-types';
22
import CONST from '../CONST';
3+
import stylePropTypes from '../styles/stylePropTypes';
34

45
const propTypes = {
56
/** Text to be shown as badge near the right end. */
67
badgeText: PropTypes.string,
78

89
/** Any additional styles to apply */
910
// eslint-disable-next-line react/forbid-prop-types
10-
wrapperStyle: PropTypes.object,
11+
wrapperStyle: stylePropTypes,
1112

1213
/** Function to fire when component is pressed */
13-
onPress: PropTypes.func.isRequired,
14+
onPress: PropTypes.func,
1415

1516
/** Icon to display on the left side of component */
1617
icon: PropTypes.oneOfType([PropTypes.elementType, PropTypes.string]),
@@ -53,6 +54,9 @@ const propTypes = {
5354

5455
/** Flag to choose between avatar image or an icon */
5556
iconType: PropTypes.oneOf([CONST.ICON_TYPE_AVATAR, CONST.ICON_TYPE_ICON]),
57+
58+
/** Whether the menu item should be interactive at all */
59+
interactive: PropTypes.bool,
5660
};
5761

5862
export default propTypes;

src/libs/getButtonState.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import CONST from '../CONST';
77
* @param {Boolean} [isPressed]
88
* @param {Boolean} [isComplete]
99
* @param {Boolean} [isDisabled]
10+
* @param {Boolean} [isInteractive]
1011
* @returns {String}
1112
*/
12-
export default function (isActive = false, isPressed = false, isComplete = false, isDisabled = false) {
13+
export default function (isActive = false, isPressed = false, isComplete = false, isDisabled = false, isInteractive = true) {
14+
if (!isInteractive) {
15+
return CONST.BUTTON_STATES.DEFAULT;
16+
}
17+
1318
if (isDisabled) {
1419
return CONST.BUTTON_STATES.DISABLED;
1520
}

src/pages/ReimbursementAccount/EnableStep.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ class EnableStep extends React.Component {
9595
icon={icon}
9696
iconWidth={iconSize}
9797
iconHeight={iconSize}
98-
onPress={() => {}}
99-
wrapperStyle={{paddingHorizontal: 0, marginBottom: 12}}
98+
disabled
99+
interactive={false}
100+
wrapperStyle={[styles.ph0, styles.mb3]}
100101
/>
101102
<Text>
102103
{!isUsingExpensifyCard

0 commit comments

Comments
 (0)