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(radio): Fix radio group behavior when radio button value changed #1735

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

tinayuangao
Copy link
Contributor

When radio button value changed, if the new value matches group's value, the button should be checked.

Closes #1152

R: @jelbourn

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 5, 2016
Copy link
Member

@jelbourn jelbourn left a 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', () => {
Copy link
Member

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() {
Copy link
Member

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;
}
Copy link
Member

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?

Copy link
Contributor Author

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).

@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 12, 2016
@kara kara merged commit bbc5f6a into angular:master Nov 14, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting md-radio-group value dynamically does not change 'checked' property of md-radio-button
4 participants