@@ -21,6 +21,7 @@ import {of as observableOf, Observable, Subject, defer} from 'rxjs';
21
21
import { DialogRef } from './dialog-ref' ;
22
22
import { DialogConfig } from './dialog-config' ;
23
23
import { Directionality } from '@angular/cdk/bidi' ;
24
+ import { _IdGenerator } from '@angular/cdk/a11y' ;
24
25
import {
25
26
ComponentType ,
26
27
Overlay ,
@@ -33,16 +34,14 @@ import {startWith} from 'rxjs/operators';
33
34
import { DEFAULT_DIALOG_CONFIG , DIALOG_DATA , DIALOG_SCROLL_STRATEGY } from './dialog-injectors' ;
34
35
import { CdkDialogContainer } from './dialog-container' ;
35
36
36
- /** Unique id for the created dialog. */
37
- let uniqueId = 0 ;
38
-
39
37
@Injectable ( { providedIn : 'root' } )
40
38
export class Dialog implements OnDestroy {
41
39
private _overlay = inject ( Overlay ) ;
42
40
private _injector = inject ( Injector ) ;
43
41
private _defaultOptions = inject < DialogConfig > ( DEFAULT_DIALOG_CONFIG , { optional : true } ) ;
44
42
private _parentDialog = inject ( Dialog , { optional : true , skipSelf : true } ) ;
45
43
private _overlayContainer = inject ( OverlayContainer ) ;
44
+ private _idGenerator = inject ( _IdGenerator ) ;
46
45
47
46
private _openDialogsAtThisLevel : DialogRef < any , any > [ ] = [ ] ;
48
47
private readonly _afterAllClosedAtThisLevel = new Subject < void > ( ) ;
@@ -110,7 +109,7 @@ export class Dialog implements OnDestroy {
110
109
DialogRef < R , C >
111
110
> ;
112
111
config = { ...defaults , ...config } ;
113
- config . id = config . id || ` cdk-dialog-${ uniqueId ++ } ` ;
112
+ config . id = config . id || this . _idGenerator . getId ( ' cdk-dialog-' ) ;
114
113
115
114
if (
116
115
config . id &&
0 commit comments