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."
|
comment: "The placeholder for the username text field."
|
||||||
),
|
),
|
||||||
text: $username
|
text: $username
|
||||||
) { isBeginEditing in
|
)
|
||||||
guard isBeginEditing, errorMessage != nil else { return }
|
|
||||||
|
|
||||||
errorMessage = nil
|
|
||||||
}
|
|
||||||
.textContentType(.username)
|
.textContentType(.username)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
@ -96,6 +92,9 @@ struct LoginForm: View {
|
|||||||
.onAppear {
|
.onAppear {
|
||||||
setClearButtonIfNeeded()
|
setClearButtonIfNeeded()
|
||||||
}
|
}
|
||||||
|
.onChange(of: focusedField) { _ in
|
||||||
|
onTextFieldFocused()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +108,13 @@ private extension LoginForm {
|
|||||||
textFieldAppearance.clearButtonMode = .whileEditing
|
textFieldAppearance.clearButtonMode = .whileEditing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onTextFieldFocused() {
|
||||||
|
guard errorMessage != nil else { return }
|
||||||
|
|
||||||
|
password = ""
|
||||||
|
errorMessage = nil
|
||||||
|
}
|
||||||
|
|
||||||
func onUsernameReturnPressed() {
|
func onUsernameReturnPressed() {
|
||||||
guard !username.isEmpty else { return }
|
guard !username.isEmpty else { return }
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ fileprivate extension LoginView {
|
|||||||
} icon: {
|
} icon: {
|
||||||
if isAuthenticating {
|
if isAuthenticating {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
|
.controlSize(.regular)
|
||||||
} else {
|
} else {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user