From 23ec30f3a0078ebf2f6705fb5ebbe7ac6e1c79ea Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 20 Jul 2017 19:11:58 +0200 Subject: [PATCH] fix(radio-group): coerce disabled property (#5837) --- src/lib/radio/radio.spec.ts | 13 +++++++++++++ src/lib/radio/radio.ts | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/radio/radio.spec.ts b/src/lib/radio/radio.spec.ts index f14449a63e6..281594f1aba 100644 --- a/src/lib/radio/radio.spec.ts +++ b/src/lib/radio/radio.spec.ts @@ -67,11 +67,24 @@ describe('MdRadio', () => { } }); + it('should coerce the disabled binding on the radio group', () => { + (groupInstance as any).disabled = ''; + fixture.detectChanges(); + + radioLabelElements[0].click(); + fixture.detectChanges(); + + expect(radioInstances[0].checked).toBe(false); + expect(groupInstance.disabled).toBe(true); + }); + it('should disable click interaction when the group is disabled', () => { testComponent.isGroupDisabled = true; fixture.detectChanges(); radioLabelElements[0].click(); + fixture.detectChanges(); + expect(radioInstances[0].checked).toBe(false); }); diff --git a/src/lib/radio/radio.ts b/src/lib/radio/radio.ts index 4ece2354982..3c26ec3d244 100644 --- a/src/lib/radio/radio.ts +++ b/src/lib/radio/radio.ts @@ -186,11 +186,11 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase this._checkSelectedRadioButton(); } - /** Whether the radio group is diabled */ + /** Whether the radio group is disabled */ @Input() get disabled() { return this._disabled; } set disabled(value) { - this._disabled = value; + this._disabled = coerceBooleanProperty(value); this._markRadiosForCheck(); }