Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Abide validateInput - remove existing error classes before adding error classes #12586

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

asineath-onpoint
Copy link

@asineath-onpoint asineath-onpoint commented Sep 18, 2023

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

  • Documentation
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (anything that would change an existing functionality)
  • Maintenance (refactor, code cleaning, development tools...)

Checklist

  • I have read and follow the CONTRIBUTING.md document.
  • The pull request title and template are correctly filled.
  • The pull request targets the right branch (develop or develop-v...).
  • My commits are correctly titled and contain all relevant information.
  • I have updated the documentation accordingly to my changes (if relevant).
  • I have added tests to cover my changes (if relevant).

Remove all existing validation error classes before applying current error classes in validateInput, in order to remove messages for validation rules that have been satisfied by most recent value change, even if other rules are still invalid
@sonarcloud
Copy link

sonarcloud bot commented Sep 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant