h2qutc / angular-material-components

Angular Material Library provide extra components for every project
https://h2qutc.github.io/angular-material-components/
MIT License
331 stars 162 forks source link

Unexpected behaviour for previous/selected date #118

Open Mokette opened 4 years ago

Mokette commented 4 years ago

Hello, i've just noticed a strange behaviour when i pick a date in the datetime-picker component.

The component is init with DateX, i click on the input i pick a DateY, the DateY is correctly shown inside the input but when i click again to open the datetime-picker, the selected date on the calendar is DateX

I use it that way :

the checkDate() function doesn't modify the variables only check the duration.

Thanks for you help if you can provide some :) Stay available for further informations if needed.

Regards,

Mokette commented 4 years ago

I think i find why i didn't have toe correct behaviour, it's because i use (click)="pickerStartDate.open();" to open the calendar and not a <mat-datepicker-toggle matSuffix [for]="pickerStartDateMeeting"></mat-datepicker-toggle> So i guess the pickerStartDate.open() don't do the same action than the mat-datepicker-toggle

Is there a way to have the correct behaviour without using the mat-datepicker-toggle ?

Regards,

gandalf-3d commented 4 years ago

Same problem with angular 10.1. picker.open() does not set the last selected value.

gandalf-3d commented 4 years ago

i found a solution

  inputClick(datetimePicker: NgxMatDatetimePicker<any>) {
    if (this.form.get('field').value)
      datetimePicker._selected = this.form.get('field').value;
    datetimePicker.open();
  }