fetrarij / ngx-daterangepicker-material

Pure Angular 2+ date range picker with material design theme, a demo here:
https://fetrarij.github.io/ngx-daterangepicker-material/
MIT License
246 stars 247 forks source link

Error on selecting date with the maximum option available in singleDatePicker mode #525

Open anuragyg opened 1 year ago

anuragyg commented 1 year ago

@fetrarij Versions

Describe the bug On selection of the min and max values possible from the dropdown i.e. the year 2028 or 1973, it throws an error where it says Cannot read properties of undefined (reading 'month'). This makes the app to freeze and any click anywhere results in console error count to increase. Have tried to upgrade to latest version available of the package but same issue is still there.

To Reproduce Steps to reproduce the behavior:

  1. Open the date picker.
  2. Select the year as 2028 i.e. the highest value available in the dropdown.
  3. Error can be seen in console which breaks the reactive form.
  4. Same goes for min date as well.

Expected behavior A clear and concise description of what you expected to happen.

The date/year should get selected without any error as this behavior is only seen when we select the least and highest possible value of the year available.

Screenshots image image

Stackblitz link https://fetrarij.github.io/ngx-daterangepicker-material/reactive-forms

Additional context Faced this error in our application and tried to replicate it in the demo link and same issue seen there as well. Could you please help?

Code snippet below for reference: <input ngxDaterangepickerMd matInput class="fx-date-range" type="text" [locale]="{format: 'DD/MM/YYYY',displayFormat: 'DD/MM/YYYY'}" [opens]="'left'" [closeOnAutoApply]="true" [autoApply]="true" [singleDatePicker]="true" [linkedCalendars]="true" [showDropdowns]="true" [minDate]="minDate" formControlName="dateValue" (endDateChanged)="onEndDateChanged($event)">

Could you also please tell us how is the max year option in the dropdown 2028? Where is this being set? Also, how to resolve the error so that we can resolve this issue in our app as well. Appreciate the help. Thanks in advance.