Skip to content

fix!: prevent initial validation when radio-group is initialized as invalid - #4156

Merged
vursen merged 3 commits into
masterfrom
fix/radio-group/prevent-initial-validation
Jul 9, 2022
Merged

vursen merged 3 commits into
masterfrom
fix/radio-group/prevent-initial-validation

Conversation

@vursen

@vursen vursen commented Jul 8, 2022 •

Copy link
Copy Markdown
Contributor

Description

The PR prevents the initial validation that could previously take place when radio-group is initially provided with a non-empty value and is initially marked invalid.

Warning
I marked the PR as breaking because it changes the default value of the value property to an empty string.

Without this change, it was not possible to distinguish whether the value has been changed manually via the property.

Part of #4150

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.

@DiegoCardoso DiegoCardoso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vursen
vursen marked this pull request as draft July 8, 2022 12:42
@vursen

vursen commented Jul 8, 2022 •

Copy link
Copy Markdown
Contributor Author

I realized that I haven't thought over the case when there is an initially checked radio button. Even with the PR's changes, the initial validation still happens in that case.

Let me double-check if this case matters for Flow validation.

@vursen

vursen commented Jul 8, 2022 •

Copy link
Copy Markdown
Contributor Author

I realized that I haven't thought over the case when there is an initially checked radio button. Even with the PR's changes, the initial validation still happens in that case.

Confirmed that the above drawback doesn't matter for Flow RadioGroup: its setValue() sets both the value property and checked on the radio button so the value property observer becomes invoked only once and furthermore it all happens before the web component is added to the DOM.

In other words, the current fix should be enough for the original Flow validation problem.

@vursen
vursen marked this pull request as ready for review July 8, 2022 14:20
@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2022

Copy link
Copy Markdown

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.

3 participants