Fixed the error cleanup when any of the text field is focused in the LoginForm component.
This commit is contained in:
parent
07defd0045
commit
a2f7a7f0f7
@ -38,11 +38,7 @@ struct LoginForm: View {
|
||||
comment: "The placeholder for the username text field."
|
||||
),
|
||||
text: $username
|
||||
) { isBeginEditing in
|
||||
guard isBeginEditing, errorMessage != nil else { return }
|
||||
|
||||
errorMessage = nil
|
||||
}
|
||||
)
|
||||
.textContentType(.username)
|
||||
.lineLimit(1)
|
||||
.autocapitalization(.none)
|
||||
@ -96,6 +92,9 @@ struct LoginForm: View {
|
||||
.onAppear {
|
||||
setClearButtonIfNeeded()
|
||||
}
|
||||
.onChange(of: focusedField) { _ in
|
||||
onTextFieldFocused()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +108,13 @@ private extension LoginForm {
|
||||
textFieldAppearance.clearButtonMode = .whileEditing
|
||||
}
|
||||
|
||||
func onTextFieldFocused() {
|
||||
guard errorMessage != nil else { return }
|
||||
|
||||
password = ""
|
||||
errorMessage = nil
|
||||
}
|
||||
|
||||
func onUsernameReturnPressed() {
|
||||
guard !username.isEmpty else { return }
|
||||
|
||||
|
@ -97,6 +97,7 @@ fileprivate extension LoginView {
|
||||
} icon: {
|
||||
if isAuthenticating {
|
||||
ProgressView()
|
||||
.controlSize(.regular)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user