angular / angular/components

bug(MatDialog): Tokens from lazy module are not available in another module's popup component

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

説明

#### Reproduction

https://stackblitz.com/edit/angular-material-dialog-token-from-lazy-module?file=src%2Fapp%2F%2Bteacher%2Fcomponents%2Fteacher-page%2Fteacher-page.ts

Steps to reproduce:
1. go to /teacher route
2. click open popup
3. see an exception on `ContentComponents` token access inside `HomeworkPopupComponent`

#### Expected Behavior

`MatDialog` uses passed ViewContainerRef`s injector as a parent for popup component, so it's expected to have all tokens from such injector available inside popup
https://github.com/angular/components/blob/c34511eec93461596a7febd95fa6a85f6949cdac/src/material/dialog/dialog.ts#L298

#### Actual Behavior

```
ERROR
Error: R3InjectorError(AppModule)[InjectionToken ContentComponents -> InjectionToken ContentComponents -> InjectionToken ContentComponents]:
NullInjectorError: No provider for InjectionToken ContentComponents!
```

`ContentComponents` token is available from TeacherPageComponent's `viewContainerRef.injector`.
Also it's available from `@SkipSelf() private injector: Injector` inside HomeworkPopupComponent. But we can't use this hack because we need this token deep in HomeworkPopupComponent's children.

#### Environment

- Angular: 11.2.3
- CDK/Material: 11.2.2
- Browser(s): Chrome Version 88.0.4324.182
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

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

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

調査の方向性

リンクされている StackBlitz の再現を実行し、src/app/+teacher/components/teacher-page/teacher-page.ts、HomeworkPopupComponent、および dialog.ts の298行目付近にリンクされている MatDialog のエントリポイントを調査します。ViewContainerRef インジェクターをポップアップとその子コンポーネントを通して追跡します。ContentComponents が例外なしで利用可能になれば完了です。

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

評価

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

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

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