Skip to content

Commit

Permalink
add seperate useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcecodedeveloper committed Dec 24, 2023
1 parent f2b4a9b commit 1acf4f7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,23 @@ function LoginForm(props) {
// eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to call this function when component is mounted
}, []);

useEffect(() => {
if (props.account.isLoading !== false) {
return;
}
isLoading.current = false;
}, [props.account.isLoading]);

useEffect(() => {
if (props.blurOnSubmit) {
input.current.blur();
}
if (props.account.isLoading === false) {
isLoading.current = false;
}
// Only focus the input if the form becomes visible again, to prevent the keyboard from automatically opening on touchscreen devices after signing out
if (!input.current || prevIsVisible || !props.isVisible) {
return;
}
input.current.focus();
}, [props.blurOnSubmit, props.isVisible, prevIsVisible, props.account.isLoading]);
}, [props.blurOnSubmit, props.isVisible, prevIsVisible]);

useImperativeHandle(props.innerRef, () => ({
isInputFocused() {
Expand Down

0 comments on commit 1acf4f7

Please sign in to comment.