Skip to content

Commit aa112fe

Browse files
Copilotrenemadsen
andcommitted
Add automatic overlay container management in AppComponent for all dialogs
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 1176bc4 commit aa112fe

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

eform-client/src/app/components/app.component.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
import {AuthStateService} from 'src/app/common/store';
1313
import {TranslateService} from '@ngx-translate/core';
1414
import { SpinnerComponent } from './eform-spinner/spinner.component';
15+
import { MatDialog } from '@angular/material/dialog';
16+
import { CustomOverlayContainer } from 'src/app/common/services/custom-overlay-container.service';
1517

1618
@Component({
1719
selector: 'app-root',
@@ -28,9 +30,30 @@ export class AppComponent implements OnInit, OnDestroy {
2830
private ngTitle = inject(Title);
2931
private titleService = inject(TitleService);
3032
private authSyncStorageService = inject(AuthSyncStorageService);
33+
private dialog = inject(MatDialog);
34+
private overlayContainer = inject(CustomOverlayContainer);
3135

3236
public selectIsAuth$ = this.authStore.select(selectAuthIsAuth);
3337

38+
constructor() {
39+
// Automatically move overlay container into dialogs for Angular 21 popover compatibility
40+
// This ensures dropdowns (mtx-select, ng-select) appear above modal content
41+
this.dialog.afterOpened.subscribe(dialogRef => {
42+
// Use setTimeout to ensure dialog element is in DOM
43+
setTimeout(() => {
44+
const dialogElement = document.querySelector('.mat-mdc-dialog-container');
45+
if (dialogElement) {
46+
this.overlayContainer.setContainerParent(dialogElement as HTMLElement);
47+
}
48+
}, 0);
49+
50+
// Restore overlay container when dialog closes
51+
dialogRef.afterClosed().subscribe(() => {
52+
this.overlayContainer.restoreContainerParent();
53+
});
54+
});
55+
}
56+
3457
ngOnInit(): void {
3558
this.authSyncStorageService.init();
3659
this.selectIsAuth$.pipe(debounceTime(1000), take(1)).subscribe((isAuth) => {

0 commit comments

Comments
 (0)