bug(Overlay): how can i set default panelClass to cdkConnectedOverlay
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
### Is this a regression?
- [x] Yes, this behavior used to work in the previous version
### The previous version in which this bug was not present was
19.x
### Description
### v19
In Angular CDK v19, I rewrote the overlay behavior to automatically apply different built-in panelClass values depending on the context. This allowed my custom default panelClass to coexist with user-provided panelClass values without being overridden.
```
@Injectable()
export class TestOverlay extends Overlay {
private getOverlayPanelClasses(config: OverlayConfig) {
let classes = ['test']; //'test' is only for examples
if (config.panelClass) {
if (Array.isArray(config.panelClass)) {
classes = classes.concat(config.panelClass);
} else {
classes.push(config.panelClass as string);
}
}
return classes;
}
create(config?: OverlayConfig): OverlayRef {
const overlayConfig: OverlayConfig = {
...config,
panelClass: this.getOverlayPanelClasses(config)
};
return super.create(overlayConfig);
}
}
```
### v21
After upgrading to Angular CDK v21 and switching to injection via the `CDK_CONNECTED_OVERLAY_DEFAULT_CONFIG` token, I found that whenever a component provides `cdkConnectedOverlayPanelClass` , the default panelClass I set through the default config gets completely overridden.
```
{
provide: CDK_CONNECTED_OVERLAY_DEFAULT_CONFIG,
useFactory: () => {
return {
panelClass: 'test',
};
}
}
```
There are many places in my project where cdkConnectedOverlayPanelClass is used. What should I change now?
### Reproduction
StackBlitz link:
Steps to reproduce:
1.
2.
### Expected Behavior
Provide a way to set a default class for panelClass.
### Actual Behavior
Setting CDK_CONNECTED_OVERLAY_DEFAULT_CONFIG is completely overridden by the custom input.
### Environment
- Angular: 21
- CDK/Material: 21
- Browser(s): any
- Operating System (e.g. Windows, macOS, Ubuntu):
コントリビューションガイド
調査の方向性
まず、接続されたオーバーレイの実装で CDK_CONNECTED_OVERLAY_DEFAULT_CONFIG と cdkConnectedOverlayPanelClass input がどのように組み合わされているかを追跡します。v19 のカスタム Overlay.create の動作と v21 のデフォルト設定パスを比較し、デフォルトのパネルクラスと input のパネルクラスをマージすべきかどうかを示す再現可能なテストケースを特定します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100