fix: Abide validateInput - remove existing error classes before adding error classes #12586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: Abide validateInput - Remove all existing validation error classes from an input before applying current error classes, in order to remove error messages for validation rules that have been satisfied by the most recent value change, even if other rules are still invalid
Description
In this scenario, an input has two validation rules, each rule with a corresponding validation message using the "data-form-error-on" attribute. First enter a value that both validation rules consider invalid. Then change the value to something that one validation rule considers invalid but the other considers valid. Both validation messages still remain visible.
In the existing "validateInput" logic, the error classes (by default: is-invalid-label, is-visible) only get removed from the validation messages once the input passes all validation rules. This results in some error messages staying visible even when their rules have since been satisfied, resulting in inaccurate feedback to the user.
This small update adjusts the relevant portion of "validateInput" to first remove all error classes and then add the error classes based on the current set of "failedValidators".
Types of changes
Checklist
develop
ordevelop-v...
).