diff --git a/src/material/timepicker/timepicker.ts b/src/material/timepicker/timepicker.ts index 23efc3e45565..e1628a2ef7b3 100644 --- a/src/material/timepicker/timepicker.ts +++ b/src/material/timepicker/timepicker.ts @@ -44,7 +44,7 @@ import {Overlay, OverlayRef} from '@angular/cdk/overlay'; import {TemplatePortal} from '@angular/cdk/portal'; import {_getEventTarget} from '@angular/cdk/platform'; import {ENTER, ESCAPE, hasModifierKey, TAB} from '@angular/cdk/keycodes'; -import {ActiveDescendantKeyManager} from '@angular/cdk/a11y'; +import {_IdGenerator, ActiveDescendantKeyManager} from '@angular/cdk/a11y'; import type {MatTimepickerInput} from './timepicker-input'; import { generateOptions, @@ -55,9 +55,6 @@ import { } from './util'; import {Subscription} from 'rxjs'; -/** Counter used to generate unique IDs. */ -let uniqueId = 0; - /** Event emitted when a value is selected in the timepicker. */ export interface MatTimepickerSelected { value: D; @@ -157,7 +154,7 @@ export class MatTimepicker implements OnDestroy, MatOptionParentComponent { readonly activeDescendant: Signal = this._activeDescendant.asReadonly(); /** Unique ID of the timepicker's panel */ - readonly panelId = `mat-timepicker-panel-${uniqueId++}`; + readonly panelId: string = inject(_IdGenerator).getId('mat-timepicker-panel-'); /** Whether ripples within the timepicker should be disabled. */ readonly disableRipple: InputSignalWithTransform = input(