MCPcopy Create free account
hub / github.com/angular/components / CdkDialogContainer

Class CdkDialogContainer

src/cdk/dialog/dialog-container.ts:73–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 },
72})
73export class CdkDialogContainer<C extends DialogConfig = DialogConfig>
74 extends BasePortalOutlet
75 implements DialogContainer, OnDestroy
76{
77 protected _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
78 protected _focusTrapFactory = inject(FocusTrapFactory);
79 readonly _config: C;
80 private _interactivityChecker = inject(InteractivityChecker);
81 protected _ngZone = inject(NgZone);
82 private _focusMonitor = inject(FocusMonitor);
83 private _renderer = inject(Renderer2);
84 protected readonly _changeDetectorRef = inject(ChangeDetectorRef);
85 private _injector = inject(Injector);
86 private _platform = inject(Platform);
87 protected _document = inject(DOCUMENT);
88
89 /** The portal outlet inside of this container into which the dialog content will be loaded. */
90 @ViewChild(CdkPortalOutlet, {static: true}) _portalOutlet!: CdkPortalOutlet;
91
92 _focusTrapped: Observable<void> = new Subject<void>();
93
94 /** The class that traps and manages focus within the dialog. */
95 private _focusTrap: FocusTrap | null = null;
96
97 /** Element that was focused before the dialog was opened. Save this to restore upon close. */
98 private _elementFocusedBeforeDialogWasOpened: HTMLElement | null = null;
99
100 /**
101 * Type of interaction that led to the dialog being closed. This is used to determine
102 * whether the focus style will be applied when returning focus to its original location
103 * after the dialog is closed.
104 */
105 _closeInteractionType: FocusOrigin | null = null;
106
107 /**
108 * Queue of the IDs of the dialog's label element, based on their definition order. The first
109 * ID will be used as the `aria-labelledby` value. We use a queue here to handle the case
110 * where there are two or more titles in the DOM at a time and the first one is destroyed while
111 * the rest are present.
112 */
113 _ariaLabelledByQueue: string[] = [];
114
115 private _isDestroyed = false;
116
117 constructor() {
118 super();
119
120 // Callback is primarily for some internal tests
121 // that were instantiating the dialog container manually.
122 this._config = (inject(DialogConfig, {optional: true}) || new DialogConfig()) as C;
123
124 if (this._config.ariaLabelledBy) {
125 this._ariaLabelledByQueue.push(this._config.ariaLabelledBy);
126 }
127 }
128
129 _addAriaLabelledBy(id: string) {
130 this._ariaLabelledByQueue.push(id);

Callers

nothing calls this directly

Calls 3

_contentAttachedMethod · 0.95
hasAttachedMethod · 0.65

Tested by

no test coverage detected