angular / angular/components

bug(OverlayContainer, MatDialog): MatDialog not rendering inside custom OverlayContainer in angular 15

オープン
#26,542 コメント 5 件 リアクション 7 件 担当者 0 名 GitHub で見る
area: cdk/overlay area: material/dialog P3 troubleshooting
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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).

```@Injectable()
export class OverlayService extends OverlayContainer{
constructor(
@Inject(DOCUMENT) _document: any,
platform: Platform,
private problem: ElementRef
) {
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:

```


....




```

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):

```




```

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/app/problem/problem.component.ts の StackBlitz reproduction から始め、OverlayService._createContainer の実装とコンポーネントレベルの OverlayContainer provider を調査します。レンダリングされた DOM を期待される custom-container 構造と比較し、その後、Angular 15 で MatDialog がそのコンテナを使用することを確認します。完了条件は、ダイアログが body の直下ではなく、カスタム cdk-overlay-container の内部に追加されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。