question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(mat-date-range-picker): When used with angular forms, `valueChanges` is fired multiple times.

See original GitHub issue

Expected Behavior

Observable should emit only once per change

Actual Behavior

When listening on the formGroup, it fires 4 times, and when listening on start or end it fires 2 times

Bug demo

https://stackblitz.com/edit/angular-date-range-bug

Environment

  • Angular: 10
  • CDK/Material: 10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
theorlovskycommented, Aug 31, 2021

a less ugly workaround:

this.form.valueChanges.pipe(auditTime(0)).subscribe(...);
0reactions
weilinzungcommented, Sep 29, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactive forms valueChanges method fires twice for one ...
If you want to take only first response and keep listening for changes on the Reactive Form with distinctUntilChanged(), you can use ......
Read more >
FormArray - Angular
This method performs strict checks, and throws an error if you try to set the value of a control that doesn't exist or...
Read more >
How to do Conditional Validation on valueChanges method in ...
In this blog post, we will learn to use Angular Reactive Forms value change detection and enable conditional validation on basis of that....
Read more >
Angular - Angular inDepth
When using Reactive Forms the default way of disabling a FormControl is by using the ... Well, if we click several times on...
Read more >
Datepicker - Angular Material
If you want your users to select a range of dates, instead of a single date, you can use the mat-date-range-input and mat-date-range-picker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found