material icon indicating copy to clipboard operation
material copied to clipboard

datepicker: invalid value on first load from moment

Open j-walker23 opened this issue 4 years ago • 4 comments
trafficstars

Bug Report

Demo URL (required)*: https://datepicker-invalid-value-on-first-load-from-string-12075-pskwl4.stackblitz.io

Detailed Reproduction Steps

  1. Start date as moment object

List the affected versions of AngularJS, Material, OS, and browsers

  • AngularJS: 1.8.2
  • AngularJS Material: 1.2.3
  • OS: All
  • Browsers: All
  • Screen Readers:

Add anything else we should know

This was just fixed for string being the default last version. I added the below to that ticket, but I added it too late. I should have just opened a new ticket. Sorry about that.

When DatePickerCtrl.prototype.updateErrorState is called with a moment date if (this.dateUtil.isValidDate(date)) { is false So this.ngModelCtrl.$setValidity('valid', date == null); runs and the ngModel ctrl valid key is set to false.

j-walker23 avatar Aug 08 '21 08:08 j-walker23

Thank you for opening this issue. Sorry that I didn't notice your comment in https://github.com/angular/material/issues/12075 and address that as well in PR https://github.com/angular/material/pull/12115.

Splaktar avatar Nov 18 '21 21:11 Splaktar

@Splaktar it seems this bug is also present if you use the Luxon Adapter instead of the Moment Adapter

matrium0 avatar Jan 02 '22 19:01 matrium0

@matrium0 AngularJS Material doesn't have an official Luxon adapter. Which are you using?

Splaktar avatar Jan 02 '22 23:01 Splaktar

Ah sorry, I noticed a similar bug in MatLuxonDateModule (installed via @angular/material-luxon-adapter) for Angular not AngularJS.

My bad! (still I choose to blame it a tiny little bit on the choice to "keep the name" Angular :D ). Thanks for your quick response!

matrium0 avatar Jan 03 '22 00:01 matrium0