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

Do not focus the input on screen exit transition #15050

Merged
merged 1 commit into from
Feb 16, 2023
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
12 changes: 9 additions & 3 deletions src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {View} from 'react-native';
import React from 'react';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import KeyboardAvoidingView from '../KeyboardAvoidingView';
import CONST from '../../CONST';
import KeyboardShortcut from '../../libs/KeyboardShortcut';
Expand Down Expand Up @@ -40,10 +41,15 @@ class ScreenWrapper extends React.Component {
Navigation.setIsNavigating(true);
});

this.unsubscribeTransitionEnd = this.props.navigation.addListener('transitionEnd', () => {
this.setState({didScreenTransitionEnd: true});
this.props.onTransitionEnd();
this.unsubscribeTransitionEnd = this.props.navigation.addListener('transitionEnd', (event) => {
Navigation.setIsNavigating(false);

// Prevent firing the prop callback when user is exiting the page.
if (lodashGet(event, 'data.closing')) {
return;
}
this.setState({didScreenTransitionEnd: true});
this.props.onEntryTransitionEnd();
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/ScreenWrapper/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const propTypes = {
/** Whether to include padding top */
includePaddingTop: PropTypes.bool,

// Called when navigated Screen's transition is finished.
onTransitionEnd: PropTypes.func,
// Called when navigated Screen's transition is finished. It does not fire when user exit the page.
onEntryTransitionEnd: PropTypes.func,

/** The behavior to pass to the KeyboardAvoidingView, requires some trial and error depending on the layout/devices used.
* Search 'switch(behavior)' in ./node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js for more context */
Expand All @@ -34,7 +34,7 @@ const defaultProps = {
style: [],
includeSafeAreaPaddingBottom: true,
includePaddingTop: true,
onTransitionEnd: () => {},
onEntryTransitionEnd: () => {},
modal: {},
keyboardAvoidingViewBehavior: 'padding',
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/AddSecondaryLoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AddSecondaryLoginPage extends Component {
render() {
return (
<ScreenWrapper
onTransitionEnd={() => {
onEntryTransitionEnd={() => {
if (!this.phoneNumberInputRef) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/PasswordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class PasswordPage extends Component {
render() {
const shouldShowNewPasswordPrompt = !this.state.errors.newPassword && !this.state.errors.newPasswordSameAsOld;
return (
<ScreenWrapper onTransitionEnd={() => {
<ScreenWrapper onEntryTransitionEnd={() => {
if (!this.currentPasswordInputRef) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Payments/AddPayPalMePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AddPayPalMePage extends React.Component {

render() {
return (
<ScreenWrapper onTransitionEnd={this.focusPayPalMeInput}>
<ScreenWrapper onEntryTransitionEnd={this.focusPayPalMeInput}>
<HeaderWithCloseButton
title={this.props.translate('common.payPalMe')}
shouldShowBackButton
Expand Down