diff --git a/Sources/Skyflow/elements/TextField.swift b/Sources/Skyflow/elements/TextField.swift index 526e949a..5dd938f3 100644 --- a/Sources/Skyflow/elements/TextField.swift +++ b/Sources/Skyflow/elements/TextField.swift @@ -403,11 +403,10 @@ extension TextField { func updateErrorMessage() { var isRequiredCheckFailed = false - - let currentState = state.getState() + var currentState = state.getState() if self.errorTriggered == false { // Error styles - if (currentState["isEmpty"] as! Bool || self.actualValue.isEmpty) { + if (currentState["isEmpty"] as! Bool || self.actualValue.isEmpty || self.hasFocus) { if currentState["isRequired"] as! Bool { isRequiredCheckFailed = true updateInputStyle(collectInput!.inputStyles.invalid) diff --git a/Sources/Skyflow/elements/TextFieldValidationDelegate.swift b/Sources/Skyflow/elements/TextFieldValidationDelegate.swift index 76c919b2..f6816dde 100644 --- a/Sources/Skyflow/elements/TextFieldValidationDelegate.swift +++ b/Sources/Skyflow/elements/TextFieldValidationDelegate.swift @@ -106,6 +106,7 @@ internal class TextFieldValidationDelegate: NSObject, UITextFieldDelegate { // label styles on focus collectField.updateLabelStyle(collectField.collectInput!.labelStyles.focus) collectField.onFocusHandler?((collectField.state as! StateforText).getStateForListener()) + collectField.resetError() } /// Wrap native `UITextField` delegate method for `didEndEditing`. diff --git a/Sources/Skyflow/elements/core/state/StateforText.swift b/Sources/Skyflow/elements/core/state/StateforText.swift index bc1b53bd..08978945 100644 --- a/Sources/Skyflow/elements/core/state/StateforText.swift +++ b/Sources/Skyflow/elements/core/state/StateforText.swift @@ -76,7 +76,6 @@ internal class StateforText: State result["validationError"] = validationError result["isCustomRuleFailed"] = isCustomRuleFailed result["isDefaultRuleFailed"] = isDefaultRuleFailed - return result }