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

Radio buttons do not become unchecked when a bound ngModel property is removed #327

Closed
pmulac opened this issue Apr 18, 2016 · 2 comments · Fixed by #441
Closed

Radio buttons do not become unchecked when a bound ngModel property is removed #327

pmulac opened this issue Apr 18, 2016 · 2 comments · Fixed by #441
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@pmulac
Copy link

pmulac commented Apr 18, 2016

Consider the following radio group:

<md-radio-group  [ngModel]="model.accountType" ngControl="accountType">
    <md-radio-button value="I">Individual</md-radio-button>
    <md-radio-button value="J">Joint</md-radio-button>
</md-radio-group>

And then the ngModel object changes like so:

Original state: {accountType: 'J'}
New state: {}

I would expect the corresponding radio button ('Joint') to be unchecked. However, the 'Joint' radio button remains checked, which does not represent the true state of the control.

As a workaround, I'm able to bind to the md-radio-checked class on each button, which removes the checked state of a radio button when the corresponding binding changes to undefined.

<md-radio-group  [ngModel]="model.accountType" ngControl="accountType">
    <md-radio-button value="I" [class.md-radio-checked]="model.accountType === 'I'">Individual</md-radio-button>
    <md-radio-button value="J" [class.md-radio-checked]="model.accountType === 'J'">Joint</md-radio-button>
</md-radio-group>

This is especially important for a redux/ngrx application, in which you would expect radio buttons to become checked/unchecked as you replay recorded actions.

@jelbourn jelbourn added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 18, 2016
@jelbourn jelbourn added this to the alpha.5 milestone Apr 18, 2016
@lobo-tuerto
Copy link

I'm observing the same behavior with reactive forms :(

@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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants