bug(material/datepicker): Adding a max to a datepicker input will fire valueChanges
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 91
描述
### Documentation Feedback
Currently the [documentation ](https://angular.io/api/forms/AbstractControl#valueChanges)only says that valueChanges will fire 'every time the value of the control changes' or 'each time you call enable() or disable()' however, I've also found valueChanges to fire if two inputs with datepickers rely upon one another for min and max.
My scenario is a period that has a start and end date. The start date cannot be after the end date, similarly the end date cannot be before the start. So basically my two form fields look like this:
```
```
and
```
```
What I've found is that the valueChanges of startDate will emit whenever the endDate is changed because of the startDate max.
It doesn't seem obvious in the documentation that setting the mib or max will cause the value of the control to change.
Here's a [stackblitz](https://stackblitz.com/edit/reactive-form-validation-angular-15-swfz9e?file=src/app/app.component.html).
Steps to reproduce:
1: Select a start date and see that its value is logged to the console via the valueChanges subscription on startDate.
2: Now make a change to the endDate field and note that the startDate valueChanges emits again.
3: Remove the [max]="period.get('endDate')?.value" from the startDate input and notice that the issue goes away.
### Affected documentation page
https://angular.io/api/forms/AbstractControl#valueChanges
贡献指南
调研方向
从受影响的 AbstractControl.valueChanges 文档页面开始,并复现链接的 StackBlitz 场景。确认更改 datepicker 的 min/max 时相关 control 会发出事件,然后更新文档以描述该行为;当页面准确涵盖所报告的情况时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100