Gets the aria-labelledby of the select component trigger.
()
| 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. |