Skip to content

Commit

Permalink
Refactor BaseLoginForm and remove isFocused from props
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed Nov 30, 2023
1 parent 3d7bb9a commit d2cb714
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import GoogleSignIn from '@components/SignInButtons/GoogleSignIn';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withNavigationFocus from '@components/withNavigationFocus';
import withToggleVisibilityView from '@components/withToggleVisibilityView';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import usePrevious from '@hooks/usePrevious';
Expand Down Expand Up @@ -76,9 +75,6 @@ const propTypes = {

isVisible: PropTypes.bool.isRequired,

/** Whether navigation is focused */
isFocused: PropTypes.bool.isRequired,

...windowDimensionsPropTypes,

...withLocalizePropTypes,
Expand All @@ -102,7 +98,7 @@ function LoginForm(props) {
const [formError, setFormError] = useState(false);
const prevIsVisible = usePrevious(props.isVisible);
const firstBlurred = useRef(false);
const isFocusedLocal = useIsFocused();
const isFocused = useIsFocused();

const {translate} = props;

Expand Down Expand Up @@ -206,10 +202,11 @@ function LoginForm(props) {
useEffect(() => {
// Just call clearAccountMessages on the login page (home route), because when the user is in the transition route and not yet authenticated,
// this component will also be mounted, resetting account.isLoading will cause the app to briefly display the session expiration page.
if (props.isFocused && props.isVisible) {

if (isFocused && props.isVisible) {
Session.clearAccountMessages();
}
if (!canFocusInputOnScreenFocus() || !input.current || !props.isVisible || !isFocusedLocal) {
if (!canFocusInputOnScreenFocus() || !input.current || !props.isVisible || !isFocused) {
return;
}
let focusTimeout;
Expand Down Expand Up @@ -348,7 +345,6 @@ const LoginFormWithRef = forwardRef((props, ref) => (
LoginFormWithRef.displayName = 'LoginFormWithRef';

export default compose(
withNavigationFocus,
withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
Expand Down

0 comments on commit d2cb714

Please sign in to comment.