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: force the validation to check for bad user input #4268

Merged
merged 1 commit into from
Jul 23, 2022

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Jul 22, 2022

Description

The PR overrides checkValidity for number-field to force it to check for bad user input before anything else.

Earlier, number-field could stay valid after you have entered something bad in the case of no constraints. This behavior was coming from InputConstraintsMixin which doesn't check native validity when no constraints. This is generally correct behavior. The exception is input[type=number] fields where the native checkValidity also checks for bad input.

Fixes #4258

Type of change

  • Bugfix

Checklist

  • I have read the contribution guide: https://vaadin.com/docs-beta/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@vursen vursen requested a review from web-padawan July 22, 2022 14:45
@vursen vursen force-pushed the fix/number-field/validate-for-bad-user-input branch from 0b459dc to 69acea9 Compare July 22, 2022 14:46
@vursen vursen changed the title fix: check for bad user input in validation fix: force the validation to check for bad user input Jul 22, 2022
});

it('should be valid when committing a valid number', async () => {
await sendKeys({ type: '1' });
Copy link
Contributor Author

@vursen vursen Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no choice other than to use sendKeys here because programmatically setting an invalid value on number inputs is prevented by the browser.

@sonarcloud
Copy link

sonarcloud bot commented Jul 22, 2022

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

@vursen vursen merged commit dd81c6a into master Jul 23, 2022
@vursen vursen deleted the fix/number-field/validate-for-bad-user-input branch July 23, 2022 11:02
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.

[number-field] The field is not validated when trying to commit a non-parsable value
2 participants