Skip to content

Commit 865165b

Browse files
authored
Merge pull request #9347 from allroundexperts/fix-8935
Fix: Remove button isn't disabled when a user is removed by pressing Enter
2 parents f9d7870 + d36c345 commit 865165b

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

src/components/Button.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -257,36 +257,39 @@ class Button extends Component {
257257
]}
258258
nativeID={this.props.nativeID}
259259
>
260-
{({pressed, hovered}) => (
261-
<OpacityView
262-
shouldDim={pressed}
263-
style={[
264-
styles.button,
265-
this.props.small ? styles.buttonSmall : undefined,
266-
this.props.medium ? styles.buttonMedium : undefined,
267-
this.props.large ? styles.buttonLarge : undefined,
268-
this.props.extraLarge ? styles.buttonExtraLarge : undefined,
269-
this.props.success ? styles.buttonSuccess : undefined,
270-
this.props.danger ? styles.buttonDanger : undefined,
271-
(this.props.isDisabled && this.props.success) ? styles.buttonSuccessDisabled : undefined,
272-
(this.props.isDisabled && this.props.danger) ? styles.buttonDangerDisabled : undefined,
273-
(this.props.isDisabled && !this.props.danger && !this.props.success) ? styles.buttonDisable : undefined,
274-
(this.props.success && hovered) ? styles.buttonSuccessHovered : undefined,
275-
(this.props.danger && hovered) ? styles.buttonDangerHovered : undefined,
276-
this.props.shouldRemoveRightBorderRadius ? styles.noRightBorderRadius : undefined,
277-
this.props.shouldRemoveLeftBorderRadius ? styles.noLeftBorderRadius : undefined,
278-
...this.props.innerStyles,
279-
]}
280-
>
281-
{this.renderContent()}
282-
{this.props.isLoading && (
283-
<ActivityIndicator
284-
color={(this.props.success || this.props.danger) ? themeColors.textReversed : themeColors.text}
285-
style={[styles.pAbsolute, styles.l0, styles.r0]}
286-
/>
287-
)}
288-
</OpacityView>
289-
)}
260+
{({pressed, hovered}) => {
261+
const activeAndHovered = !this.props.isDisabled && hovered;
262+
return (
263+
<OpacityView
264+
shouldDim={pressed}
265+
style={[
266+
styles.button,
267+
this.props.small ? styles.buttonSmall : undefined,
268+
this.props.medium ? styles.buttonMedium : undefined,
269+
this.props.large ? styles.buttonLarge : undefined,
270+
this.props.extraLarge ? styles.buttonExtraLarge : undefined,
271+
this.props.success ? styles.buttonSuccess : undefined,
272+
this.props.danger ? styles.buttonDanger : undefined,
273+
(this.props.isDisabled && this.props.success) ? styles.buttonSuccessDisabled : undefined,
274+
(this.props.isDisabled && this.props.danger) ? styles.buttonDangerDisabled : undefined,
275+
(this.props.isDisabled && !this.props.danger && !this.props.success) ? styles.buttonDisable : undefined,
276+
(this.props.success && activeAndHovered) ? styles.buttonSuccessHovered : undefined,
277+
(this.props.danger && activeAndHovered) ? styles.buttonDangerHovered : undefined,
278+
this.props.shouldRemoveRightBorderRadius ? styles.noRightBorderRadius : undefined,
279+
this.props.shouldRemoveLeftBorderRadius ? styles.noLeftBorderRadius : undefined,
280+
...this.props.innerStyles,
281+
]}
282+
>
283+
{this.renderContent()}
284+
{this.props.isLoading && (
285+
<ActivityIndicator
286+
color={(this.props.success || this.props.danger) ? themeColors.textReversed : themeColors.text}
287+
style={[styles.pAbsolute, styles.l0, styles.r0]}
288+
/>
289+
)}
290+
</OpacityView>
291+
);
292+
}}
290293
</Pressable>
291294
);
292295
}

0 commit comments

Comments
 (0)