angular-material-components icon indicating copy to clipboard operation
angular-material-components copied to clipboard

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

Open Raphyyy opened this issue 2 years ago • 2 comments

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 avatar Mar 17 '22 15:03 Raphyyy

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 avatar Mar 29 '22 08:03 Raphyyy

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

Raphyyy avatar Apr 05 '22 09:04 Raphyyy