|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | import {
|
| 10 | + _IdGenerator, |
10 | 11 | ActiveDescendantKeyManager,
|
11 | 12 | addAriaReferencedId,
|
12 | 13 | LiveAnnouncer,
|
@@ -96,8 +97,6 @@ import {
|
96 | 97 | } from './select-errors';
|
97 | 98 | import {NgClass} from '@angular/common';
|
98 | 99 |
|
99 |
| -let nextUniqueId = 0; |
100 |
| - |
101 | 100 | /** Injection token that determines the scroll handling while a select is open. */
|
102 | 101 | export const MAT_SELECT_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrategy>(
|
103 | 102 | 'mat-select-scroll-strategy',
|
@@ -215,6 +214,7 @@ export class MatSelect
|
215 | 214 | protected _changeDetectorRef = inject(ChangeDetectorRef);
|
216 | 215 | readonly _elementRef = inject(ElementRef);
|
217 | 216 | private _dir = inject(Directionality, {optional: true});
|
| 217 | + private _idGenerator = inject(_IdGenerator); |
218 | 218 | protected _parentFormField = inject<MatFormField>(MAT_FORM_FIELD, {optional: true});
|
219 | 219 | ngControl = inject(NgControl, {self: true, optional: true})!;
|
220 | 220 | private _liveAnnouncer = inject(LiveAnnouncer);
|
@@ -312,7 +312,7 @@ export class MatSelect
|
312 | 312 | private _compareWith = (o1: any, o2: any) => o1 === o2;
|
313 | 313 |
|
314 | 314 | /** Unique id for this input. */
|
315 |
| - private _uid = `mat-select-${nextUniqueId++}`; |
| 315 | + private _uid = this._idGenerator.getId('mat-select-'); |
316 | 316 |
|
317 | 317 | /** Current `aria-labelledby` value for the select trigger. */
|
318 | 318 | private _triggerAriaLabelledBy: string | null = null;
|
@@ -367,7 +367,7 @@ export class MatSelect
|
367 | 367 | _onTouched = () => {};
|
368 | 368 |
|
369 | 369 | /** ID for the DOM node containing the select's value. */
|
370 |
| - _valueId = `mat-select-value-${nextUniqueId++}`; |
| 370 | + _valueId = this._idGenerator.getId('mat-select-value-'); |
371 | 371 |
|
372 | 372 | /** Emits when the panel element is finished transforming in. */
|
373 | 373 | readonly _panelDoneAnimatingStream = new Subject<string>();
|
|
0 commit comments