Skip to content

Commit

Permalink
Merge pull request #27947 from tienifr/fix/22388
Browse files Browse the repository at this point in the history
Fix: Transition animation does not work for request money page
  • Loading branch information
roryabraham authored Sep 25, 2023
2 parents 2f492e4 + 673acb3 commit f20eba2
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/pages/iou/steps/NewRequestAmountPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useCallback, useEffect, useRef} from 'react';
import {InteractionManager, View} from 'react-native';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import {useFocusEffect} from '@react-navigation/native';
Expand Down Expand Up @@ -69,22 +69,17 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) {

const currency = CurrencyUtils.isValidCurrencyCode(currentCurrency) ? currentCurrency : iou.currency;

const focusTextInput = () => {
// Component may not be initialized due to navigation transitions
// Wait until interactions are complete before trying to focus
InteractionManager.runAfterInteractions(() => {
// Focus text input
if (!textInput.current) {
return;
}

textInput.current.focus();
});
};
const focusTimeoutRef = useRef(null);

useFocusEffect(
useCallback(() => {
focusTextInput();
focusTimeoutRef.current = setTimeout(() => textInput.current && textInput.current.focus(), CONST.ANIMATED_TRANSITION);
return () => {
if (!focusTimeoutRef.current) {
return;
}
clearTimeout(focusTimeoutRef.current);
};
}, []),
);

Expand Down Expand Up @@ -175,7 +170,6 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) {
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableKeyboardAvoidingView={false}
onEntryTransitionEnd={focusTextInput}
testID={NewRequestAmountPage.displayName}
>
{({safeAreaPaddingBottomStyle}) => (
Expand Down

0 comments on commit f20eba2

Please sign in to comment.