Skip to content
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
6 changes: 3 additions & 3 deletions goldens/material/radio/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any;
// @public (undocumented)
export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy {
constructor(...args: unknown[]);
ariaDescribedby: string;
ariaLabel: string;
ariaLabelledby: string;
ariaDescribedby: string | null;
ariaLabel: string | null;
ariaLabelledby: string | null;
readonly change: EventEmitter<MatRadioChange>;
get checked(): boolean;
set checked(value: boolean);
Expand Down
24 changes: 18 additions & 6 deletions src/material/radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,12 @@ describe('MatRadio', () => {
testComponent.ariaLabel = 'Pineapple';
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();

expect(fruitRadioNativeInputs[0].getAttribute('aria-label')).toBe('Pineapple');

testComponent.ariaLabel = null;
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();
expect(fruitRadioNativeInputs[0].hasAttribute('aria-label')).toBe(false);
});

it('should add aria-labelledby attribute to the underlying input element if defined', () => {
Expand All @@ -834,8 +838,12 @@ describe('MatRadio', () => {
testComponent.ariaLabelledby = 'uvw';
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();

expect(fruitRadioNativeInputs[0].getAttribute('aria-labelledby')).toBe('uvw');

testComponent.ariaLabelledby = null;
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();
expect(fruitRadioNativeInputs[0].hasAttribute('aria-labelledby')).toBe(false);
});

it('should add aria-describedby attribute to the underlying input element if defined', () => {
Expand All @@ -852,8 +860,12 @@ describe('MatRadio', () => {
testComponent.ariaDescribedby = 'uvw';
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();

expect(fruitRadioNativeInputs[0].getAttribute('aria-describedby')).toBe('uvw');

testComponent.ariaDescribedby = null;
fixture.changeDetectorRef.markForCheck();
fixture.detectChanges();
expect(fruitRadioNativeInputs[0].hasAttribute('aria-describedby')).toBe(false);
});

it('should focus on underlying input element when focus() is called', () => {
Expand Down Expand Up @@ -1117,9 +1129,9 @@ class RadiosInsidePreCheckedRadioGroup {}
imports: [MatRadioModule, FormsModule, ReactiveFormsModule],
})
class StandaloneRadioButtons {
ariaLabel: string = 'Banana';
ariaLabelledby: string = 'xyz';
ariaDescribedby: string = 'abc';
ariaLabel: string | null = 'Banana';
ariaLabelledby: string | null = 'xyz';
ariaDescribedby: string | null = 'abc';
}

@Component({
Expand Down
6 changes: 3 additions & 3 deletions src/material/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@ export class MatRadioButton implements OnInit, AfterViewInit, DoCheck, OnDestroy
@Input() name!: string;

/** Used to set the 'aria-label' attribute on the underlying input element. */
@Input('aria-label') ariaLabel!: string;
@Input('aria-label') ariaLabel!: string | null;

/** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */
@Input('aria-labelledby') ariaLabelledby!: string;
@Input('aria-labelledby') ariaLabelledby!: string | null;

/** The 'aria-describedby' attribute is read after the element's label and field type. */
@Input('aria-describedby') ariaDescribedby!: string;
@Input('aria-describedby') ariaDescribedby!: string | null;

/** Whether ripples are disabled inside the radio button */
@Input({transform: booleanAttribute})
Expand Down
Loading