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

Selecting any date without range throws an Error in console and broke the functionality. #514

Closed sunrawat closed 1 year ago

sunrawat commented 1 year ago

Versions

Describe the bug Selecting any date without range throws an Error in console Cannot read properties of undefined (reading 'selectedHour'). I was also able to reproduce the issue in official website also and all the Web application using this plugin or module. Whether in Jquery, Javascript or Angular applications.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://fetrarij.github.io/ngx-daterangepicker-material/custom-ranges
  2. Click on date field
  3. Click on any date once only and click Done
  4. Open the console and see the error

Expected behavior Current selected start date(02/022/2023) should be selected for example 02/022/2023 - 02/022/2023 I should have take start date as the end date on (one selection) instead throwing error.

Screenshots image

Stackblitz link https://fetrarij.github.io/ngx-daterangepicker-material/custom-ranges

Additional context Issue is coming from there in the code:

function which is causing issue: timepickerVariables

clickApply(e) { if (!this.singleDatePicker && this.startDate && !this.endDate) { this.endDate = this.getDateWithTime(this.startDate, SideEnum.right); this.calculateChosenLabel(); } }

getDateWithTime(date, side) { let hour = parseInt(String(this.timepickerVariables[side].selectedHour), 10); <<<< source of error

Hope we'll get an update soon.

sunrawat commented 1 year ago

@fetrarij Do you have any updates on this?

hannata commented 1 year ago

any updates ?

Sky4CE commented 1 year ago

If you have global error handler implemented in your project then it is not possible to suppress this error. @fetrarij please give your thoughts about this

hannata commented 1 year ago

so we downgrade and keep on using the old version for now ?

i am currently using it with angular 15, then i had this issue, after downgrading it worked but i get a warning

Warning: /Users/greybell/Documents/imonitor-v3/node_modules/ngx-daterangepicker-material/__ivy_ngcc__/fesm2015/ngx-daterangepicker-material.js depends on 'dayjs/plugin/customParseFormat'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

sunrawat commented 1 year ago

Shall we proceed with the Pull Request Raised and merge it? @hannata @Sky4CE @fetrarij

hannata commented 1 year ago

@sunrawat now im using the latest version as i need the esm version of dayjs in it, but the selectedhour error keeps on showing , any solution on how to fix it, and as i mentioned previously we are using angular 15

hannata commented 1 year ago

gents, im gonna downgrade now, until it has a stable version that can fix this issue and ill upgrade, as i can handle warnings, but the error breaks the app @fetrarij

Sky4CE commented 1 year ago

@hannata the only way suppress it is too add special case in global error handler and match against exact text, but this is too ugly. By the way what version did you downgrade to avoid this error ?

hannata commented 1 year ago

@hannata the only way suppress it is too add special case in global error handler and match against exact text, but this is too ugly. By the way what version did you downgrade to avoid this error ?

to version ^5.0.2 @Sky4CE

Sky4CE commented 11 months ago

Hi @fetrarij , could you inform please when you plan to release this fix to npm ?

hannata commented 7 months ago

hello everyone, i want to upgrade to angular 17, so first im upgrading to angular 16, but i was getting an erro from the daterange package, i has to upgrade it too, so now im back with the selectedHour issue, any update on this ? and how can we solve it ?

hannata commented 6 months ago

any updates ?