-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/overlayarea: material/dialogtroubleshootingThis issue is not reporting an issue, but just asking for helpThis issue is not reporting an issue, but just asking for help
Description
In Angular 15, if a component is provided with OverlayContainer and overridden to use it as a custom container element, individual overlay elements are not rendering inside the container (), instead is appended to the document body(default behavior).
export class OverlayService extends OverlayContainer{
constructor(
@Inject(DOCUMENT) _document: any,
platform: Platform,
private problem: ElementRef<HTMLElement>
) {
super(_document, platform);
}
protected override _createContainer(): void {
const containerClass = "cdk-overlay-container";
const container = this._document.createElement("div");
container.classList.add(containerClass);
this.problem.nativeElement.appendChild(container);
this._containerElement = container;
}
}
@Component({
selector: 'app-problem',
templateUrl: './problem.component.html',
styleUrls: ['./problem.component.css'],
providers: [
DialogServiceService,
MatDialog,
{ provide: OverlayContainer, useClass: OverlayService },
]
})
Expected behavior:
<body>
<app-problem>
<div>....</div>
<div class="cdk-overlay-container">
<mat-dialog-container></mat-dialog-container>
</div>
</app-problem>
</body>
I was expecting the MatDialog to render inside the custom container as in previous angular versions.
What troubleshooting steps have you tried?
Current behavior(Angular 15):
<body>
<app-problem></app-problem>
</body>
<div class="cdk-overlay-container">
<mat-dialog-container></mat-dialog-container>
</div>
Reproduction
https://stackblitz.com/edit/angular-pfwikb?file=src%2Fapp%2Fproblem%2Fproblem.component.ts
Environment
- Angular: 15
- CDK/Material: 15.1.2
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Mac
maciekprzysowa, KG3RK3N, noguespi, lacastorine, EvanBor and 1 more
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/overlayarea: material/dialogtroubleshootingThis issue is not reporting an issue, but just asking for helpThis issue is not reporting an issue, but just asking for help