@@ -18,6 +18,7 @@ import {
18
18
EnvironmentInjector ,
19
19
inject ,
20
20
} from '@angular/core' ;
21
+ import { _IdGenerator } from '@angular/cdk/a11y' ;
21
22
import { _CdkPrivateStyleLoader } from '@angular/cdk/private' ;
22
23
import { OverlayKeyboardDispatcher } from './dispatchers/overlay-keyboard-dispatcher' ;
23
24
import { OverlayOutsideClickDispatcher } from './dispatchers/overlay-outside-click-dispatcher' ;
@@ -27,9 +28,6 @@ import {OverlayRef} from './overlay-ref';
27
28
import { OverlayPositionBuilder } from './position/overlay-position-builder' ;
28
29
import { ScrollStrategyOptions } from './scroll/index' ;
29
30
30
- /** Next overlay unique ID. */
31
- let nextUniqueId = 0 ;
32
-
33
31
/**
34
32
* Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
35
33
* used as a low-level building block for other components. Dialogs, tooltips, menus,
@@ -51,6 +49,7 @@ export class Overlay {
51
49
private _location = inject ( Location ) ;
52
50
private _outsideClickDispatcher = inject ( OverlayOutsideClickDispatcher ) ;
53
51
private _animationsModuleType = inject ( ANIMATION_MODULE_TYPE , { optional : true } ) ;
52
+ private _idGenerator = inject ( _IdGenerator ) ;
54
53
55
54
private _appRef : ApplicationRef ;
56
55
private _styleLoader = inject ( _CdkPrivateStyleLoader ) ;
@@ -106,7 +105,7 @@ export class Overlay {
106
105
private _createPaneElement ( host : HTMLElement ) : HTMLElement {
107
106
const pane = this . _document . createElement ( 'div' ) ;
108
107
109
- pane . id = ` cdk-overlay-${ nextUniqueId ++ } ` ;
108
+ pane . id = this . _idGenerator . getId ( ' cdk-overlay-' ) ;
110
109
pane . classList . add ( 'cdk-overlay-pane' ) ;
111
110
host . appendChild ( pane ) ;
112
111
0 commit comments