Skip to content

Moment date adapter with Material datepicker strict mode issue #17235

@brgrz

Description

@brgrz

Reproduction

Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/angular-qn3txm

Steps to reproduce:

  1. Strict mode for moment adapter is turned on in app.module providers section
  2. valuechanges is set up at the form
  3. When user starts typing in date, for instance types in "10" and stops, the valuechanges should fire with the value of Moment date object being invalid (invalid: true).
  4. Currently it fires with the Moment date value being expanded to 10/01/2019, making it valid date. Now, this could be ok behaviour prior we had the strict mode or when strict mode is off but not when it is turned on.

Expected Behavior

For incomplete dates entered into the form the Datepicker/Moment date adapter currently works in a way of "autocompleting" the value to the current month, which is unwanted when strict mode in turned on.

Actual Behavior

If user enters "10" currently the datepicker/dateadapter expands it to 10/1/2019 (for default en-us locale being in use). Even when strict mode is on.

What behavior were you expecting to see?

The Moment value from the datepicker value should be invalid (or maybe null).

Environment

  • Angular: 8.2.8
  • CDK/Material: 8.2.1
  • Browser(s): latest chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions