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
1 change: 0 additions & 1 deletion goldens/material/chips/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
protected _allTrailingIcons: QueryList<MatChipTrailingIcon>;
_animationsDisabled: boolean;
ariaDescription: string | null;
_ariaDescriptionId: string;
ariaLabel: string | null;
protected basicChipAttrName: string;
// (undocumented)
Expand Down
6 changes: 2 additions & 4 deletions src/material/chips/chip-option.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<button
matChipAction
[_allowFocusWhenDisabled]="true"
[attr.aria-selected]="ariaSelected"
[attr.aria-description]="ariaDescription"
[attr.aria-label]="ariaLabel"
[attr.aria-describedby]="_ariaDescriptionId"
[attr.aria-selected]="ariaSelected"
role="option">
@if (_hasLeadingGraphic()) {
<span class="mdc-evolution-chip__graphic mat-mdc-chip-graphic">
Expand Down Expand Up @@ -35,5 +35,3 @@
<ng-content select="mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"></ng-content>
</span>
}

<span class="cdk-visually-hidden" [id]="_ariaDescriptionId">{{ariaDescription}}</span>
21 changes: 3 additions & 18 deletions src/material/chips/chip-option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,25 +337,10 @@ describe('Option Chips', () => {

expect(optionElement.getAttribute('aria-label')).toMatch(/option name/i);

const optionElementDescribedBy = optionElement!.getAttribute('aria-describedby');
expect(optionElementDescribedBy)
.withContext('expected primary grid cell to have a non-empty aria-describedby attribute')
const optionElementDescription = optionElement!.getAttribute('aria-description');
expect(optionElementDescription)
.withContext('expected primary grid cell to have a non-empty aria-description attribute')
.toBeTruthy();

const optionElementDescriptions = Array.from(
(fixture.nativeElement as HTMLElement).querySelectorAll(
optionElementDescribedBy!
.split(/\s+/g)
.map(x => `#${x}`)
.join(','),
),
);

const optionElementDescription = optionElementDescriptions
.map(x => x.textContent?.trim())
.join(' ')
.trim();

expect(optionElementDescription).toMatch(/option description/i);
});

Expand Down
6 changes: 2 additions & 4 deletions src/material/chips/chip-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<span class="mdc-evolution-chip__cell mdc-evolution-chip__cell--primary" role="gridcell"
matChipAction
[disabled]="disabled"
[attr.aria-label]="ariaLabel"
[attr.aria-describedby]="_ariaDescriptionId">
[attr.aria-description]="ariaDescription"
[attr.aria-label]="ariaLabel">
@if (leadingIcon) {
<span class="mdc-evolution-chip__graphic mat-mdc-chip-graphic">
<ng-content select="mat-chip-avatar, [matChipAvatar]"></ng-content>
Expand Down Expand Up @@ -40,5 +40,3 @@
<ng-content select="mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"></ng-content>
</span>
}

<span class="cdk-visually-hidden" [id]="_ariaDescriptionId">{{ariaDescription}}</span>
21 changes: 3 additions & 18 deletions src/material/chips/chip-row.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,25 +468,10 @@ describe('Row Chips', () => {

expect(primaryGridCell!.getAttribute('aria-label')).toMatch(/chip name/i);

const primaryGridCellDescribedBy = primaryGridCell!.getAttribute('aria-describedby');
expect(primaryGridCellDescribedBy)
.withContext('expected primary grid cell to have a non-empty aria-describedby attribute')
const primaryGridCellDescription = primaryGridCell!.getAttribute('aria-description');
expect(primaryGridCellDescription)
.withContext('expected primary grid cell to have a non-empty aria-description attribute')
.toBeTruthy();

const primaryGridCellDescriptions = Array.from(
(fixture.nativeElement as HTMLElement).querySelectorAll(
primaryGridCellDescribedBy!
.split(/\s+/g)
.map(x => `#${x}`)
.join(','),
),
);

const primaryGridCellDescription = primaryGridCellDescriptions
.map(x => x.textContent?.trim())
.join(' ')
.trim();

expect(primaryGridCellDescription).toMatch(/chip description/i);
});
});
Expand Down
3 changes: 0 additions & 3 deletions src/material/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
/** ARIA description for the content of the chip. */
@Input('aria-description') ariaDescription: string | null = null;

/** Id of a span that contains this chip's aria description. */
_ariaDescriptionId = `${this.id}-aria-description`;

/** Whether the chip list is disabled. */
_chipListDisabled: boolean = false;

Expand Down
Loading