bug(MatDatePicker): change events emitted despite using emitEvents false
See original GitHub issueReproduction
https://stackblitz.com/edit/components-issue-xay9ty?file=src%2Fapp%2Fexample-component.ts
- Click the “emitEvent: false” button
Expected Behavior
valueChanges
should not emit values when setting a value with emitEvent: false
This works correctly for “normal” input components, but not when attaching a date picker.
The reproduction includes a text input and a select for comparison.
Actual Behavior
Using setValue
or patchValue
with emitEvent
set to false
has the valueChanges
observable emit changes.
Environment
- Angular: 10.0.3
- CDK/Material: 10.0.3
- Browser: Chrome
- Operating System: Windows
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Angular Material mat-datepicker (change) event and format
When I open date picker dialog and select any date, date shows up in input text box, but I want to call a...
Read more >Issue With The Mat-Datepicker In A Loop - ADocLib
For example, if <mat-datepicker> is configured to work with javascript ... bug(MatDatePicker): change events emitted despite using emitEvents false #20218.
Read more >UNPKG - @angular/material
_focusIndex = value;\n }\n\n /** Event emitted when the option is selected. ... 0));\n\n // If there is a change in selected index,...
Read more >angular/angular - Gitter
<mat-form-field> <input matInput [matDatepicker]="startPicker" ... in that service which you use to emit events from the app-navbar and you ...
Read more >Datepicker input and change events - StackBlitz
Dependencies · <mat-form-field> · <input matInput [matDatepicker]="picker" · placeholder="Input & change events" · (dateInput)="addEvent('input', · $event)" ( ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I encountered this bug aswell.
I have a formGroup (attached to a <mat-date-range-*> inside the template):
readonly myRange = new FormGroup({ start: new FormControl({ value: null, disabled: true }), end: new FormControl({ value: null, disabled: true }), });
I do listnen to the value changes, with nothing special, just to console log the value.
this.myRange.valueChanges.subscribe(console.log);
Later in my code I patch the value with emit false.
this.myRange.patchValue({ start: new Date(2020, 9, 5), end: new Date(2020, 9, 10) }, { emitEvent: false });
The value is correctly set, but I don’t expect the console.log to show anything.
Edit: added a stack blitz to show the issue: https://stackblitz.com/edit/angular-ivy-hgtnqf?file=src%2Fapp%2Fapp.component.ts
The problem is in interface, we are setting
emitEvent
option, but FormControl component check old option nameemitViewModelChange
.