components icon indicating copy to clipboard operation
components copied to clipboard

Material Datepicker problem in IE 11

Open kirillika opened this issue 9 years ago • 8 comments

Bug

There seems to be a problem with the date picker when used as shown below. When "9/2a9/2017" is entered into the input field, IE 11 errs out with this message: TypeError: Invalid procedure call or argument. (notice the 'a' in there).

When this happens, ngModelChange is not triggered and there is no validation error coloring/text rendered for the input field.

Another problem with IE 11 is similar. When "a9/29/2017" is entered, there is no validation error coloring/text rendered for the input field, however, ngModelChange is triggered, but the date that is passed with the event is decremented by one day, so the result is 9/28/2017. There is a workaround to read the value of the input field as soon as the ngModelChange event comes in and validate the date with custom logic, so this problem is less severe than the first one, but still...

What are the steps to reproduce?

HTML:

` <input mdInput [mdDatepicker]="picker" placeholder={{label}} [ngModel]="myDate" (ngModelChange)="updateMyDate($event,true)" [max]="maxDate" #dateInput>

<md-hint align="end">mm / dd / yyyy</md-hint>
<md-error *ngIf="dateFormControl.hasError('required')">
  Valid date is <strong>required</strong>
</md-error>
<md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle>
<md-datepicker #picker ></md-datepicker>
`

TS:

public dateFormControl:FormControl = new FormControl('', [ Validators.required ]);

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

IE 11

"dependencies": { "@angular/animations": "^4.4.3", "@angular/cdk": "^2.0.0-beta.11", "@angular/common": "^4.4.3", "@angular/compiler": "^4.4.3", "@angular/compiler-cli": "^4.4.3", "@angular/core": "^4.4.3", "@angular/forms": "^4.4.3", "@angular/http": "^4.4.3", "@angular/material": "^2.0.0-beta.11", "@angular/platform-browser": "^4.4.3", "@angular/platform-browser-dynamic": "^4.4.3", "@angular/platform-server": "^4.4.3", "@angular/router": "^4.4.3", "classlist.js": "^1.1.20150312", "core-js": "^2.4.1", "rxjs": "^5.4.2", "typescript": "^2.5.3", "zone.js": "^0.8.14" }

kirillika avatar Sep 29 '17 07:09 kirillika

Why open another issue? #7406

donroyco avatar Sep 29 '17 07:09 donroyco

Can you please provide a reproduction case using Plunker/StackBlitz?

josephperrott avatar Sep 29 '17 16:09 josephperrott

Here is the sample I created by inserting the datepicker into the template at StackBlitz:

https://stackblitz.com/edit/angular-material2-issue-j3nv8f

The code is very simple.

It loads in FF and Chrome. It does not load in IE 11. If you can get passed IE 11 errors (shown below) related to the StackBlitz project template code, you should be able to reproduce the issue.

IE 11 errors:

Unhandled promise rejection Error: Object doesn't support property or method 'includes'

kirillika avatar Sep 29 '17 18:09 kirillika

@kirillika here you can get polyfill :)

includes mdn

djleonskennedy avatar Oct 02 '17 10:10 djleonskennedy

Closing since this is a polyfill issue.

jelbourn avatar Jan 17 '18 00:01 jelbourn

Why was this closed there is still an issue with material Datepicker when using IE11. You can simply see the issue by opening the following page with IE11, the calendar comes up blank.

https://material.angular.io/components/datepicker/overview

tabruzzomufg avatar Dec 04 '18 19:12 tabruzzomufg

the following solution handles that issue as well. https://github.com/angular/material2/issues/15400

ayoubde avatar Mar 21 '19 15:03 ayoubde

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.