Skip to content

bug(mat-datepicker): dateChange not firing on blur #33442

Description

@pcurrivan

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

17

Description

Calling blur() on the datepicker input (e.g. when the Enter key is pressed) no longer triggers a dateChange event. It used to do so in Angular 17.

If this is intended, is there a supported way to complete an edit of the input and cause a dateChange event when the Enter key is pressed?

Reproduction

Stackblitz reproduction: https://stackblitz.com/edit/dsxjb9lf

This is a fork of this example: https://material.angular.dev/components/datepicker/examples#datepicker-overview
I added a dateChange handler and a keydown handler to the input, and a div that shows that last emitted dateChange event's value.

(The stackblitz isn't running for me after forking and saving it and I don't know why. If it doesn't run for you, you should be able to copy the contents of datepicker-overview-example.html and datepicker-overview-example.ts from my stackblitz to the example stackblitz and that should run.)

Instructions:

  • enter a date string in the datepicker input (e.g. "2020") and then click outside the input. Notice the date appears below.
  • enter a different date string in the datepicker input (e.g. "2021") and press Enter. Notice the date does not appear below.

Expected Behavior

dateChange fires

Actual Behavior

dateChange doesn't fire

Environment

  • Angular: 21.2 / 22.0
  • CDK/Material: 21.2 / 22.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions