angular / angular/components

bug(MatDatePicker): NativeDatePicker not using the correct format initially

未关闭
#31,107 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
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

When I use the following setup:

```

provideNativeDateAdapter({
parse: {
dateInput: 'DD.MM.YYYY',
},
display: {
dateInput: 'DD.MM.YYYY',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
}),
{
provide: LOCALE_ID,
useValue: 'de-CH'
},
```

the DatePicker will show the date in the wrong format: "13.5.2025" instead of "13.05.2025". Why are the format options ignored?

### Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

### Expected Behavior

Date is formatted as "13.05.2025".

### Actual Behavior

Date is formatted as "13.5.2025".

### Environment

- Angular: 19.1.4
- CDK/Material: 19.1.5
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

贡献指南

打开贡献指南

调研方向

从 issue 中显示的 NativeDatePicker 和 provideNativeDateAdapter 配置开始,使用 de-CH locale 和提供的 dateInput 格式。复现初始显示,并追踪配置的格式被忽略的原因;当 picker 初始将日期显示为 "13.05.2025" 时即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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