h2qutc / angular-material-components

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

[bug] Setting `(focus)="picker.open()"` cause the selected datetime not being updated on next opening #255

Open Raphyyy opened 2 years ago

Raphyyy commented 2 years ago

Hi and thanks for your work,

When opened trough (focus)="picker.open()" on the input element, the inner selected datetime is not being updated when you reopen it the next time.

Stackblitz : https://stackblitz.com/edit/demo-ngx-mat-datetime-picker-angular9-tpxldn?file=src%2Fapp%2Fapp.component.html (Its basically the same sketch as in the README with (focus)="picker.open()" added on the input element)

Step to reproduce :

  1. Click somewhere on the input element (elsewhere than on the calendar icon) to open the datepicker
  2. Change the date or the time
  3. Click on the validate button
  4. Open the datepicker again : The displayed datetime in the datepicker is not reflecting the input value, it's showing the old value

Using click instead of focus doesn't fix it neither.

Raphyyy commented 2 years ago

Hi @h2qutc sorry to bother you but do you have any quick workaround to do this ? From usage code or even from the package itself I could patch with patch-package, I'll take

Raphyyy commented 2 years ago

I find a workaround by replacing (focus)="picker.open()" with (focus)="picker._selected = formControl.value; picker.open()", with formControl.value refering to the datetime value