From 1d4349dd21a2e41ea1ef2be9d08c3150e5deb047 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 13 May 2025 14:36:18 -0700 Subject: [PATCH] fix(material/radio): updating required value should mark for check This change ensures that updates to the required value of the radio button also mark the component for check, ensuring OnPush compatibility. --- src/material/radio/radio.spec.ts | 3 +-- src/material/radio/radio.ts | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/material/radio/radio.spec.ts b/src/material/radio/radio.spec.ts index 94f5f98d422f..0d2e0ccb5af4 100644 --- a/src/material/radio/radio.spec.ts +++ b/src/material/radio/radio.spec.ts @@ -1,5 +1,5 @@ import {dispatchFakeEvent} from '@angular/cdk/testing/private'; -import {Component, DebugElement, provideCheckNoChangesConfig, ViewChild} from '@angular/core'; +import {Component, DebugElement, ViewChild} from '@angular/core'; import {ComponentFixture, TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing'; import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms'; import {By} from '@angular/platform-browser'; @@ -14,7 +14,6 @@ import { describe('MatRadio', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - providers: [provideCheckNoChangesConfig({exhaustive: false})], imports: [ MatRadioModule, FormsModule, diff --git a/src/material/radio/radio.ts b/src/material/radio/radio.ts index 61e2df4c60fb..7a545cdd0f33 100644 --- a/src/material/radio/radio.ts +++ b/src/material/radio/radio.ts @@ -523,6 +523,9 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy return this._required || (this.radioGroup && this.radioGroup.required); } set required(value: boolean) { + if (value !== this._required) { + this._changeDetector.markForCheck(); + } this._required = value; }