Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Modal freezing issue on Payments page #8173

Merged
merged 3 commits into from
Mar 20, 2022
Merged
Changes from 2 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
23 changes: 18 additions & 5 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import {View, TouchableOpacity, Dimensions} from 'react-native';
import {
View, TouchableOpacity, Dimensions, InteractionManager, LayoutAnimation,
} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PaymentMethodList from '../PaymentMethodList';
import ROUTES from '../../../../ROUTES';
Expand Down Expand Up @@ -197,6 +199,9 @@ class BasePaymentsPage extends React.Component {

hidePasswordPrompt() {
this.setState({shouldShowPasswordPrompt: false});

// Fixes iOS Freeze issue
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
}

makeDefaultPaymentMethod(password) {
Expand Down Expand Up @@ -316,9 +321,13 @@ class BasePaymentsPage extends React.Component {
<TouchableOpacity
onPress={() => {
this.setState({
shouldShowPasswordPrompt: true,
shouldShowDefaultDeleteMenu: false,
passwordButtonText: this.props.translate('paymentsPage.setDefaultConfirmation'),
});
InteractionManager.runAfterInteractions(() => {
this.setState({
shouldShowPasswordPrompt: true,
passwordButtonText: this.props.translate('paymentsPage.setDefaultConfirmation'),
});
});
}}
style={[styles.button, styles.alignSelfCenter, styles.w100]}
Expand All @@ -332,7 +341,11 @@ class BasePaymentsPage extends React.Component {
onPress={() => {
this.setState({
shouldShowDefaultDeleteMenu: false,
shouldShowConfirmPopover: true,
});
InteractionManager.runAfterInteractions(() => {
this.setState({
shouldShowConfirmPopover: true,
});
});
}}
style={[
Expand Down Expand Up @@ -364,7 +377,7 @@ class BasePaymentsPage extends React.Component {
isDangerousAction
/>
<ConfirmPopover
contentStyles={[!this.props.isSmallScreenWidth ? styles.sidebarPopover : '']}
contentStyles={!this.props.isSmallScreenWidth ? [styles.sidebarPopover] : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change to undefined instead of [""] which was there previously? Just curious.

Otherwise just missing the comments and we should be good to go.

Copy link
Member Author

@parasharrajat parasharrajat Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to undefined is like resetting it. So it will automatically take dfaultProp value for this prop.

[""] is the wrong value for this prop. It expects it to be Array<Object>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! thanks for the explanation.

isVisible={this.state.shouldShowConfirmPopover}
title={this.props.translate('paymentsPage.deleteAccount')}
prompt={this.props.translate('paymentsPage.deleteConfirmation')}
Expand Down