diff --git a/Modules/Sources/Login/UI/Components/LoginForm.swift b/Modules/Sources/Login/UI/Components/LoginForm.swift index 543dc27..5bb0711 100644 --- a/Modules/Sources/Login/UI/Components/LoginForm.swift +++ b/Modules/Sources/Login/UI/Components/LoginForm.swift @@ -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 } diff --git a/Modules/Sources/Login/UI/Views/LoginView.swift b/Modules/Sources/Login/UI/Views/LoginView.swift index 955a6f3..754fe4c 100644 --- a/Modules/Sources/Login/UI/Views/LoginView.swift +++ b/Modules/Sources/Login/UI/Views/LoginView.swift @@ -97,6 +97,7 @@ fileprivate extension LoginView { } icon: { if isAuthenticating { ProgressView() + .controlSize(.regular) } else { EmptyView() }