ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Datepicker crashes when entering text in input #112

Closed Rob-Post closed 7 years ago

Rob-Post commented 7 years ago

Steps to reproduce:

VM357 core.umd.js:3478 TypeError: Cannot read property 'fullName' of undefined
    at Ng2Datetime.getMonthData (VM359 ng2-datetime-picker.umd.js:177)
    at Ng2DatetimePickerComponent.initDatetime (VM359 ng2-datetime-picker.umd.js:316)
    at Ng2DatetimePickerDirective.updateDatepicker (VM359 ng2-datetime-picker.umd.js:607)
    at Ng2DatetimePickerDirective.ngOnChanges (VM359 ng2-datetime-picker.umd.js:602)
    at Wrapper_Ng2DatetimePickerDirective.ngDoCheck (VM419 wrapper.ngfactory.js:162)
    at CompiledTemplate.proxyViewClass.View_AppComponent0.detectChangesInternal (VM422 component.ngfactory.js:504)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (VM357 core.umd.js:12583)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (VM357 core.umd.js:12730)
    at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (VM357 core.umd.js:12568)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.detectChangesInternal (VM424 host.ngfactory.js:29)
allenhwkim commented 7 years ago

This is an enviornmental issue. It works with Chrome, but with others OS, e.g., IE. We may improve it with checking an exception with an invalid date value.

Rob-Post commented 7 years ago

I disagree, I experience this issue in

Running on Windows 10 Version 1607 14393.693

Rob-Post commented 7 years ago

Thanks for fixing this issue! Now my application doesn't crash anymore.

However, when displaying the initial value the date isn't formatted with the custom function I set via Ng2Datetime.formatDate. It now displays 2017-01-31T00:00:00+01:00 instead of 31-01-2017.

When selecting a date in the datepicker, the date gets formatted in the correct format.

This behaviour is also visible in the demo plunker.

mihailo-misic commented 7 years ago

I'm still having this issue.

Entering letters or whitespace in the input field > clicking away (blur) > clicking back on the input.

<input type="text" id="date_start" 
       formControlName="date_start" 
       ng2-datetime-picker date-only="true" 
       placeholder="DD-MM-YYYY" date-format="DD-MM-YYYY">
TypeError: Cannot read property 'fullName' of undefined
    at Ng2Datetime.getMonthData (ng2-datetime.js:113)
    at Ng2DatetimePickerComponent.ngOnInit (ng2-datetime-picker.component.js:86)
    at Wrapper_Ng2DatetimePickerComponent.ngDoCheck (/Ng2DatetimePickerModule/Ng2DatetimePickerComponent/wrapper.ngfactory.js:175)
    at CompiledTemplate.proxyViewClass.View_Ng2DatetimePickerComponent_Host0.detectChangesInternal (/Ng2DatetimePickerModule/Ng2DatetimePickerComponent/host.ngfactory.js:34)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (view.js:425)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (view.js:620)
    ...

Thank you for your time.

allenhwkim commented 7 years ago

@mihailomisic I cannot reproduce with the give info. Please create a plunker example with your browser info.

mihailo-misic commented 7 years ago

@allenhwkim Thank you for the fast response.

Plunker with the error

Just click the input field and you'll receive the error I've mentioned.
If you remove the whitespace I've set in the FormBuilder, it will work. But if you then add whitespace or letters manually, and click away, the error is there.

allenhwkim commented 7 years ago

Hmm, the code is trying to to parse ' '. I will see what I can do.

allenhwkim commented 7 years ago

@nickthakkar @ndcunningham Do you want to look into this?

maciej-karpus commented 7 years ago

Hi there, any progress in this case?

allenhwkim commented 7 years ago

@maciej-karpus this has been fixed and released.