angular / angular/components

bug(datepicker): Date range picker emit repeated events after the first date is selected

オープン
#27,322 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る
area: material/datepicker P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
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 a date range picker is opened and the start date is selected, two consecutive `valueChanges` event are triggered, and after the end date is selected the final event is triggered, in total 3 events happens instead of only two.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/shrtut?
Steps to reproduce:
1. Click on the `mat-datepicker-toggle` button.
2. Select a start date like: 6/18/2023
3. Notice on the _Changes_ section below that two events were triggered.
4. Select the end date: 6/24/2023.
5. A final event in logged on the _Changes_ section.

### Expected Behavior

After selecting the first date only a single `valueChanges` event should be triggered.

The expected behavior is show on the _Workaround Changes_ section where a `debounceTime(0)` is forced in order to remove the spurious repeated event.

### Actual Behavior

Two events are triggered after selecting the start date

### Environment

- Angular: 16.1.1
- CDK/Material: 16.1.1
- Browser(s): Firefox, Chrome.
- Operating System: Linux (Fedora)

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

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

調査の方向性

リンクされた StackBlitz の再現と、mat-datepicker-toggle および valueChanges を使用する Angular Material date range picker のフローから始めます。Changes セクションで 6/18/2023、続いて 6/24/2023 を選択する操作を再現し、その後 debounceTime(0) の回避策と比較します。完了の条件は、開始日後に 1 回、終了日後に 1 回の valueChanges イベントが発生することです。

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

評価

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

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

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