MCPcopy Create free account
hub / github.com/angular/components / _getTriggerAriaLabelledby

Method _getTriggerAriaLabelledby

src/material/select/select.ts:1354–1376  ·  view source on GitHub ↗

Gets the aria-labelledby of the select component trigger.

()

Source from the content-addressed store, hash-verified

1352
1353 /** Gets the aria-labelledby of the select component trigger. */
1354 private _getTriggerAriaLabelledby(): string | null {
1355 if (this.ariaLabel) {
1356 return null;
1357 }
1358
1359 let value = this._parentFormField?.getLabelId() || '';
1360
1361 if (this.ariaLabelledby) {
1362 value += ' ' + this.ariaLabelledby;
1363 }
1364
1365 // The value should not be used for the trigger's aria-labelledby,
1366 // but this currently "breaks" accessibility tests since they complain
1367 // there is no aria-labelledby. This is because they are not setting an
1368 // appropriate label on the form field or select.
1369 // TODO: remove this conditional after fixing clients by ensuring their
1370 // selects have a label applied.
1371 if (!value) {
1372 value = this._valueId;
1373 }
1374
1375 return value;
1376 }
1377
1378 /**
1379 * Implemented as part of MatFormFieldControl.

Callers 1

ngDoCheckMethod · 0.95

Calls 1

getLabelIdMethod · 0.65

Tested by

no test coverage detected