Skip to content

Commit

Permalink
Merge pull request #28682 from tienifr/fix/28340
Browse files Browse the repository at this point in the history
fix: 28340 Focus freeze on add contact method magic code on coming back from search
  • Loading branch information
grgia authored Oct 11, 2023
2 parents afb6f1f + 62cbf62 commit 0a20111
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import {useFocusEffect} from '@react-navigation/native';
import MagicCodeInput from '../../../../../components/MagicCodeInput';
import * as ErrorUtils from '../../../../../libs/ErrorUtils';
import withLocalize, {withLocalizePropTypes} from '../../../../../components/withLocalize';
Expand Down Expand Up @@ -77,6 +78,7 @@ function BaseValidateCodeForm(props) {
const inputValidateCodeRef = useRef();
const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin');
const shouldDisableResendValidateCode = props.network.isOffline || props.account.isLoading;
const focusTimeoutRef = useRef(null);

useImperativeHandle(props.innerRef, () => ({
focus() {
Expand All @@ -87,6 +89,21 @@ function BaseValidateCodeForm(props) {
},
}));

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

useEffect(() => {
Session.clearAccountMessages();
if (!validateLoginError) {
Expand Down
1 change: 1 addition & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,7 @@ const styles = (theme) => ({
// However, it is not possible to override the background-color directly as explained in this resource: https://developer.mozilla.org/en-US/docs/Web/CSS/:autofill
// Therefore, the transition effect needs to be delayed.
transitionDelay: '99999s',
transitionProperty: 'background-color',
}
: {}),
},
Expand Down

0 comments on commit 0a20111

Please sign in to comment.