Skip to content

Commit a13699e

Browse files
committed
refactor(material/timepicker): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent 0a6cf2f commit a13699e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/material/timepicker/timepicker.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {Overlay, OverlayRef} from '@angular/cdk/overlay';
4444
import {TemplatePortal} from '@angular/cdk/portal';
4545
import {_getEventTarget} from '@angular/cdk/platform';
4646
import {ENTER, ESCAPE, hasModifierKey, TAB} from '@angular/cdk/keycodes';
47-
import {ActiveDescendantKeyManager} from '@angular/cdk/a11y';
47+
import {_IdGenerator, ActiveDescendantKeyManager} from '@angular/cdk/a11y';
4848
import type {MatTimepickerInput} from './timepicker-input';
4949
import {
5050
generateOptions,
@@ -55,9 +55,6 @@ import {
5555
} from './util';
5656
import {Subscription} from 'rxjs';
5757

58-
/** Counter used to generate unique IDs. */
59-
let uniqueId = 0;
60-
6158
/** Event emitted when a value is selected in the timepicker. */
6259
export interface MatTimepickerSelected<D> {
6360
value: D;
@@ -157,7 +154,7 @@ export class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
157154
readonly activeDescendant: Signal<string | null> = this._activeDescendant.asReadonly();
158155

159156
/** Unique ID of the timepicker's panel */
160-
readonly panelId = `mat-timepicker-panel-${uniqueId++}`;
157+
readonly panelId: string = inject(_IdGenerator).getId('mat-timepicker-panel-');
161158

162159
/** Whether ripples within the timepicker should be disabled. */
163160
readonly disableRipple: InputSignalWithTransform<boolean, unknown> = input(

0 commit comments

Comments
 (0)