Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(radio): coerce checked input binding #8556

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/demo-app/radio/radio-demo.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1>Basic Example</h1>
<section class="demo-section">
<mat-radio-button name="group1">Option 1</mat-radio-button>
<mat-radio-button name="group1" checked>Option 1</mat-radio-button>
<mat-radio-button name="group1">Option 2</mat-radio-button>
<mat-radio-button name="group1" disabled="true">Option 3 (disabled)</mat-radio-button>
</section>
Expand Down
7 changes: 3 additions & 4 deletions src/lib/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,10 @@ export class MatRadioButton extends _MatRadioButtonMixinBase

/** Whether this radio button is checked. */
@Input()
get checked(): boolean {
return this._checked;
}
get checked(): boolean { return this._checked; }
set checked(value: boolean) {
const newCheckedState = coerceBooleanProperty(value);

set checked(newCheckedState: boolean) {
if (this._checked != newCheckedState) {
this._checked = newCheckedState;

Expand Down