-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(radio): Fix radio group behavior when radio button value changed #1735
Conversation
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.
This change likely has to be made for the button-toggle as well.
We definitely need to figure out a good way to share code between the two- TypeScript doesn't support mixins directly, so we need to come up with something.
@@ -274,6 +274,29 @@ describe('MdRadio', () => { | |||
expect(groupInstance.value).toBe('water'); | |||
expect(changeSpy).not.toHaveBeenCalled(); | |||
}); | |||
|
|||
it('should update checked status if changed value to radio group\'s value', () => { |
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.
Instead of escaping the '
, you can use a different type of quote for the string (usually backtick)
} | ||
} | ||
|
||
_checkSelectedButton() { |
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.
How about _checkSelectedRadioButton
?
radio.checked = this.value == radio.value; | ||
if (radio.checked) { | ||
this._selected = radio; | ||
} |
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.
Are we losing anything by no longer going through the setter for selected
here?
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 selected()
does 3 things: update _selected
(which is done); update value
(_updateSelectedRadioFromValue
is always called from value change) ; check selected
radio button (we get the _selected
value from checked radio buttons, and checked
is set on line 190).
5dd2965
to
32c0c2d
Compare
LGTM |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When radio button value changed, if the new value matches group's value, the button should be checked.
Closes #1152
R: @jelbourn