Skip to content

bug(DatePicker): Keyboard focus lost after selecting first date in range (accessibility failure) #29265

@Andrew-Marks-Trisept

Description

@Andrew-Marks-Trisept

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

No response

Description

When custom dateFilter functions are used to control which dates can be selected for the start and end dates on a mat-date-range-input, the keyboard focus is lost/reset after the user selects a start date. They must tab several times to get back to the right place so they can select their end date.

Note I'm dynamically switching between two different dateFilter functions, depending on which date is being selected.

This issue is causing us to fail our accessibility audit.

Reproduction

StackBlitz link: https://stackblitz.com/edit/4yvmaz?file=src%2Fexample%2Fdate-range-picker-overview-example.html

Steps to reproduce:

  1. In the Custom Date Filters Example, tab to the calendar icon and open it with Enter
  2. Use arrow keys to navigate the calendar and hit Enter to select a start date
  3. Notice the arrow keys now do nothing and you are unable to select an end date with the keyboard unless you tab several times and find the right place again.

Expected Behavior

The Custom Date Filters Example provided should work exactly like the Basic Example. After selecting a start date, you should be able to use the arrows and Enter key again to select an end date.

Actual Behavior

Focus seems to be lost or reset after the first date is selected.

I thought it might be related to the fact that the date that currently has focus (the selected start date) gets disabled in my example due to my end date requirements. But even if I allow the start date as a valid end date, the problem persists.

Environment

  • Angular: Seems to be all versions, tested here with 18.0.3
  • CDK/Material: Seems to be all versions, tested here with 18.0.3
  • Browser(s): Confirmed in Chrome, Edge and Firefox
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/a11yarea: material/datepicker

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions