components icon indicating copy to clipboard operation
components copied to clipboard

bug(material/core): Luxon date adapter not support initial Luxon DateTime object

Open Vevl opened this issue 2 years ago • 0 comments

Is this a regression?

  • No

Description

When I use Luxon DateTime object to init form control date is not visible in the datepicker.

Reproduction

  1. Create form control with luxon DateTime luxonControl = new FormControl(DateTime.now())
  2. Add this control to datepicker
<mat-form-field>
      <mat-label>Luxon datepicker</mat-label>
      <input matInput [matDatepicker]="dp" [formControl]="luxonControl" />
      <mat-hint>MM/DD/YYYY</mat-hint>
      <mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
      <mat-datepicker #dp></mat-datepicker>
</mat-form-field>
  1. Date is not visible in UI

Expected Behavior

Luxon DateTime should be parsed in deserialize method.

Here is my fork with edited code I just messed up the commit message and I don't have local environment so if somebody can test it, it would be great.

https://github.com/angular/components/compare/main...Vevl:components:vevl-patch

Actual Behavior

Datepicker not showing the date if there is a Luxon DateTime object as input.

Environment

  • Angular: ~14.2.0
  • CDK/Material: ^14.2.1
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Vevl avatar Sep 27 '22 10:09 Vevl