From adf9a22511da9bbfeb6443d22ff3ddcd40a813cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vin=C3=ADcius=20Souza?=
<39967235+vinifsouza@users.noreply.github.com>
Date: Fri, 13 Sep 2024 13:53:32 -0300
Subject: [PATCH 1/2] feat: always display next button in login page (#5238)
* feat: always display next button in login page
* feat(LoginForm): enable next button and show message when data is not filled
* feat(ForgotPasswordForm): remove disable state from 'next' button
---
src/screens/Login/ForgotPasswordForm.tsx | 3 +--
src/screens/Login/LoginForm.tsx | 12 +++++++++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/screens/Login/ForgotPasswordForm.tsx b/src/screens/Login/ForgotPasswordForm.tsx
index ec30bab4a8..8588888b87 100644
--- a/src/screens/Login/ForgotPasswordForm.tsx
+++ b/src/screens/Login/ForgotPasswordForm.tsx
@@ -144,8 +144,7 @@ export const ForgotPasswordForm = ({
variant="solid"
color={'primary'}
size="medium"
- onPress={onPressNext}
- disabled={!email}>
+ onPress={onPressNext}>
Next
diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx
index 35b124b611..1efac29360 100644
--- a/src/screens/Login/LoginForm.tsx
+++ b/src/screens/Login/LoginForm.tsx
@@ -83,12 +83,18 @@ export const LoginForm = ({
Keyboard.dismiss()
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
setError('')
- setIsProcessing(true)
const identifier = identifierValueRef.current.toLowerCase().trim()
const password = passwordValueRef.current
const authFactorToken = authFactorTokenValueRef.current
+ if (!identifier || !password) {
+ setError(_(msg`Invalid username or password`))
+ return
+ }
+
+ setIsProcessing(true)
+
try {
// try to guess the handle if the user just gave their own username
let fullIdent = identifier
@@ -325,7 +331,7 @@ export const LoginForm = ({
Connecting...
>
- ) : isReady ? (
+ ) : (
- ) : undefined}
+ )}
)
From b909ea6b46b569636c50c67b17df69348a3d8208 Mon Sep 17 00:00:00 2001
From: Eric Bailey
Date: Fri, 13 Sep 2024 11:54:20 -0500
Subject: [PATCH 2/2] Remove isReady logic
---
src/screens/Login/LoginForm.tsx | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx
index 1efac29360..9a01c04990 100644
--- a/src/screens/Login/LoginForm.tsx
+++ b/src/screens/Login/LoginForm.tsx
@@ -60,7 +60,6 @@ export const LoginForm = ({
const {track} = useAnalytics()
const t = useTheme()
const [isProcessing, setIsProcessing] = useState(false)
- const [isReady, setIsReady] = useState(false)
const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] =
useState(false)
const identifierValueRef = useRef(initialHandle || '')
@@ -163,22 +162,6 @@ export const LoginForm = ({
}
}
- const checkIsReady = () => {
- if (
- !!serviceDescription &&
- !!identifierValueRef.current &&
- !!passwordValueRef.current
- ) {
- if (!isReady) {
- setIsReady(true)
- }
- } else {
- if (isReady) {
- setIsReady(false)
- }
- }
- }
-
return (
Sign in}>
@@ -210,7 +193,6 @@ export const LoginForm = ({
defaultValue={initialHandle || ''}
onChangeText={v => {
identifierValueRef.current = v
- checkIsReady()
}}
onSubmitEditing={() => {
passwordRef.current?.focus()
@@ -239,7 +221,6 @@ export const LoginForm = ({
clearButtonMode="while-editing"
onChangeText={v => {
passwordValueRef.current = v
- checkIsReady()
}}
onSubmitEditing={onPressNext}
blurOnSubmit={false} // HACK: https://github.com/facebook/react-native/issues/21911#issuecomment-558343069 Keyboard blur behavior is now handled in onSubmitEditing