-
Notifications
You must be signed in to change notification settings - Fork 85
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: set has-value attribute on radio-button click #2862
Conversation
Kudos, SonarCloud Quality Gate passed!
|
@@ -357,10 +357,6 @@ class RadioGroup extends FieldMixin(FocusMixin(DisabledMixin(KeyboardMixin(DirMi | |||
return; | |||
} | |||
|
|||
if (this.__selectedRadioButton && this.__selectedRadioButton.value === newValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check above doesn't make much sense and it is exactly what causes the regression:
1. Consideration
When the user selects a radio-button, the __valueObserver
callback is invoked before the previously selected radio-button gets unchecked:
web-components/packages/radio-group/src/vaadin-radio-group.js
Lines 451 to 460 in bb41c56
__selectRadioButton(radioButton) { | |
if (radioButton) { | |
this.value = radioButton.value; | |
} else { | |
this.value = ''; | |
} | |
this.__radioButtons.forEach((button) => { | |
button.checked = button === radioButton; | |
}); |
...so it might happen that the __selectedRadioButton
getter returns the previously selected radio-button instead of a new one that results in the has-value attribute inconsistency.
2. Consideration
However, even if the __valueObserver
were invoked after the previously selected radio-button was unchecked, the check above wouldn't be correct: the has-value
attribute would be set only when changing the value
attribute but not when selecting a radio-button. Note, __selectedRadioButton
would be always equal to the most recently selected radio-button = that has been just selected.
This ticket/PR has been released with platform 22.0.0.alpha8 and is also targeting the upcoming stable 22.0.0 version. |
Description
The PR fixes the radio-group regression that occurred after the a11y refactoring that has been done in #2641:
Fixes #2857
Type of change
Checklist