Skip to content

Commit caf4b61

Browse files
DBowen33amysorto
authored andcommitted
fix(material/chips): remove tab-index attribute from mat-chip host (#29436)
* fix(material/chips): added role presentation to mat-chip host added role presentation to mat-chip host so that mobile SR users do not have to double swipe to traverse chip fixes b/286286473 * fix(material/chips): add aria-hidden add aria-hidden to host mat-chip so Talkback ignores element fixes b/286286473 * fix(material/chips): remove tabindex remove tabindex fixes b/286286473 * fix(material/chips): update api signature update api signature fixes b/286286473 * fix(material/chips): fix lint issue fix lint issue fixes b/286286473 * fix(material/chips): remove aria hidden remove aria hidden fixes b/286286473 (cherry picked from commit 5403b2b)
1 parent 4d6aa2e commit caf4b61

File tree

5 files changed

+3
-31
lines changed

5 files changed

+3
-31
lines changed

src/material/chips/chip-option.html

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<span class="mdc-evolution-chip__cell mdc-evolution-chip__cell--primary">
44
<button
55
matChipAction
6-
[tabIndex]="tabIndex"
76
[_allowFocusWhenDisabled]="true"
87
[attr.aria-selected]="ariaSelected"
98
[attr.aria-label]="ariaLabel"

src/material/chips/chip-row.html

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<span class="mdc-evolution-chip__cell mdc-evolution-chip__cell--primary" role="gridcell"
66
matChipAction
7-
[tabIndex]="tabIndex"
87
[disabled]="disabled"
98
[attr.aria-label]="ariaLabel"
109
[attr.aria-describedby]="_ariaDescriptionId">

src/material/chips/chip-row.ts

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export class MatChipRow extends MatChip implements AfterViewInit {
125125
_document,
126126
animationMode,
127127
globalRippleOptions,
128-
tabIndex,
129128
);
130129

131130
this.role = 'row';

src/material/chips/chip.ts

-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
ANIMATION_MODULE_TYPE,
1414
AfterContentInit,
1515
AfterViewInit,
16-
Attribute,
1716
ChangeDetectionStrategy,
1817
ChangeDetectorRef,
1918
Component,
@@ -36,7 +35,6 @@ import {
3635
afterNextRender,
3736
booleanAttribute,
3837
inject,
39-
numberAttribute,
4038
} from '@angular/core';
4139
import {
4240
MAT_RIPPLE_GLOBAL_OPTIONS,
@@ -85,7 +83,6 @@ export interface MatChipEvent {
8583
'[class._mat-animation-noopable]': '_animationsDisabled',
8684
'[id]': 'id',
8785
'[attr.role]': 'role',
88-
'[attr.tabindex]': '_getTabIndex()',
8986
'[attr.aria-label]': 'ariaLabel',
9087
'(keydown)': '_handleKeydown($event)',
9188
},
@@ -201,12 +198,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
201198
@Input({transform: booleanAttribute})
202199
disabled: boolean = false;
203200

204-
/** Tab index of the chip. */
205-
@Input({
206-
transform: (value: unknown) => (value == null ? undefined : numberAttribute(value)),
207-
})
208-
tabIndex: number = -1;
209-
210201
/** Emitted when a chip is to be removed. */
211202
@Output() readonly removed: EventEmitter<MatChipEvent> = new EventEmitter<MatChipEvent>();
212203

@@ -258,13 +249,9 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
258249
@Optional()
259250
@Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
260251
private _globalRippleOptions?: RippleGlobalOptions,
261-
@Attribute('tabindex') tabIndex?: string,
262252
) {
263253
this._document = _document;
264254
this._animationsDisabled = animationMode === 'NoopAnimations';
265-
if (tabIndex != null) {
266-
this.tabIndex = parseInt(tabIndex) ?? -1;
267-
}
268255
this._monitorFocus();
269256

270257
this._rippleLoader?.configureRipple(this._elementRef.nativeElement, {
@@ -396,14 +383,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
396383
// Empty here, but is overwritten in child classes.
397384
}
398385

399-
/** Gets the tabindex of the chip. */
400-
_getTabIndex() {
401-
if (!this.role) {
402-
return null;
403-
}
404-
return this.disabled ? -1 : this.tabIndex;
405-
}
406-
407386
/** Starts the focus monitoring process on the chip. */
408387
private _monitorFocus() {
409388
this._focusMonitor.monitor(this._elementRef, true).subscribe(origin => {

tools/public_api_guard/material/chips.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const MAT_CHIPS_DEFAULT_OPTIONS: InjectionToken<MatChipsDefaultOptions>;
5555

5656
// @public
5757
export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck, OnDestroy {
58-
constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, _ngZone: NgZone, _focusMonitor: FocusMonitor, _document: any, animationMode?: string, _globalRippleOptions?: RippleGlobalOptions | undefined, tabIndex?: string);
58+
constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, _ngZone: NgZone, _focusMonitor: FocusMonitor, _document: any, animationMode?: string, _globalRippleOptions?: RippleGlobalOptions | undefined);
5959
protected _allLeadingIcons: QueryList<MatChipAvatar>;
6060
protected _allRemoveIcons: QueryList<MatChipRemove>;
6161
protected _allTrailingIcons: QueryList<MatChipTrailingIcon>;
@@ -77,7 +77,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
7777
focus(): void;
7878
_getActions(): MatChipAction[];
7979
_getSourceAction(target: Node): MatChipAction | undefined;
80-
_getTabIndex(): number | null;
8180
_handleKeydown(event: KeyboardEvent): void;
8281
_handlePrimaryActionInteraction(): void;
8382
// (undocumented)
@@ -99,8 +98,6 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
9998
// (undocumented)
10099
static ngAcceptInputType_removable: unknown;
101100
// (undocumented)
102-
static ngAcceptInputType_tabIndex: unknown;
103-
// (undocumented)
104101
ngAfterContentInit(): void;
105102
// (undocumented)
106103
ngAfterViewInit(): void;
@@ -124,16 +121,15 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
124121
set ripple(v: MatRipple);
125122
_rippleLoader: MatRippleLoader;
126123
role: string | null;
127-
tabIndex: number;
128124
trailingIcon: MatChipTrailingIcon;
129125
get value(): any;
130126
set value(value: any);
131127
// (undocumented)
132128
protected _value: any;
133129
// (undocumented)
134-
static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", ["matChip"], { "role": { "alias": "role"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaDescription": { "alias": "aria-description"; "required": false; }; "value": { "alias": "value"; "required": false; }; "color": { "alias": "color"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "highlighted": { "alias": "highlighted"; "required": false; }; "disableRipple": { "alias": "disableRipple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "trailingIcon", "removeIcon", "_allLeadingIcons", "_allTrailingIcons", "_allRemoveIcons"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
130+
static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", ["matChip"], { "role": { "alias": "role"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaDescription": { "alias": "aria-description"; "required": false; }; "value": { "alias": "value"; "required": false; }; "color": { "alias": "color"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; "highlighted": { "alias": "highlighted"; "required": false; }; "disableRipple": { "alias": "disableRipple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "trailingIcon", "removeIcon", "_allLeadingIcons", "_allTrailingIcons", "_allRemoveIcons"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], true, never>;
135131
// (undocumented)
136-
static ɵfac: i0.ɵɵFactoryDeclaration<MatChip, [null, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
132+
static ɵfac: i0.ɵɵFactoryDeclaration<MatChip, [null, null, null, null, null, { optional: true; }, { optional: true; }]>;
137133
}
138134

139135
// @public

0 commit comments

Comments
 (0)