components
components copied to clipboard
mat-datepicker: valueChange fires without blur event with `updateOn: 'blur'` set
Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/angular-6qr4ut?file=angular.json
Steps to reproduce:
- Type a valid date in the box starting with '0' (zero)
- Wihtout blur start to delete char by char from the end
- Delete the all chars until the last one (zero char from step 1)
Expected Behavior
Nothing should happen, since the focus still in the box
Actual Behavior
valueChanges
event is fired. The changes will be pushed into an array and displayed in the page
Environment
- Angular: 9
- CDK/Material: 9
- Browser(s): Chrome (but should work in others)
- Operating System (e.g. Windows, macOS, Ubuntu): windows
- Ivy disabled
-
IMPORTANT you have to use
MatMomentDateModule
Confirmed that the date input appears to be emitting superfluous events here any time the input contains just 0
fix(material/datepicker) : value change without blur when the date starts with 0
As we see the behaviour of date picker it never adds any 0's at the start of a month or day which are single digits. May be we put the validations for the input field so that it acts as same and dosent allow the user to add zeroes at the start??? thoughts: @lautarobock @jelbourn @sandikbarr
Fixes angular#19613
@sahilmore-git But that will be a workaround. I think this behavior is a bug, those events never should be triggered
Yes I totally agree with you @lautarobock but I just found out that even if we add a character like 'a' or 'b' any character in an empty input field the event gets triggered even if it's still in focus. That's a new issue I guess. :(
We are now facing this issue as well. Whenever we attempt to enter in the date manually it instantly triggers the form value change event even those we set the form field as updateOn: 'blur'
Same goes for updateOn: 'submit'
Is there anyone working on this one ? I can try to fix it.
Hey @jelbourn this bug is not happening anymore, i believe this issue need to be closed. Btw @lautarobock if still happening with you pipe(distinctUntilChanged()) should be help you
@viniciusschuelter thanks, will close; anyone tracking this issue feel free to reopen with a reproduction if it's still occurring in the latest version
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.