angular / angular/components

bug(material-date-fns-adapter): MatDateFnsAdapter not imported into standalone dialog component

未关闭
#28,041 2 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
area: material/datepicker P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

I'm not sure if it is a bug or just how it works atm, but when using a MatDatepicker with MatDateFnsModule it will not find the DateAdapter when using this in a standalone dialog component. (it's working in all other standalone components which are not a dialog).

If I add the MatDateFnsAdapter to the imports of the component which opens the dialog, everything is fine. But with standalone components I usually expect the imports in the component that really needs it.

I prepared a StackBlitz example.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-35ebyd?file=src%2Fmain.ts
Steps to reproduce:
1. Wait for the dev server to load
2. Click "Open Dialog"
3. Click on the calendar icon in the input field
4. See the console log

### Expected Behavior

No error message should appear on the console and the datepicker should open.

### Actual Behavior

Datepicker does not open because of the console error.

### Environment

- Angular: 16.2.11
- CDK/Material: 16.2.11
- Browser(s): Edge, Chrome

贡献指南

打开贡献指南

调研方向

首先从 src/main.ts 运行链接的 StackBlitz 复现,并按照 issue 中描述的 standalone dialog 设置进行操作。确认打开 datepicker 时 MatDateFnsAdapter lookup 失败,然后验证 datepicker 能够在不产生控制台错误的情况下打开,同时将 adapter import 保持在需要它的组件本地。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。