Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
Andrew-Marks-Trisept opened this issue Jun 14, 2024 · 1 comment · Fixed by #29287
Assignees
Labels
area: cdk/a11y area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@Andrew-Marks-Trisept
Copy link

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
@Andrew-Marks-Trisept Andrew-Marks-Trisept added the needs triage This issue needs to be triaged by the team label Jun 14, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/a11y area: material/datepicker and removed needs triage This issue needs to be triaged by the team labels Jun 17, 2024
@crisbeto crisbeto self-assigned this Jun 20, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 20, 2024
…rrent view

When some calendar inputs change, we need to re-render the entire view (e.g. `minDate` or `dateFilter`). This can cause the active cell to lose focus since it's being re-rendered.

These changes schedule the active cell to be re-focused in the cases where the view would be re-rendered.

Fixes angular#29265.
crisbeto added a commit that referenced this issue Jun 25, 2024
…rrent view (#29287)

When some calendar inputs change, we need to re-render the entire view (e.g. `minDate` or `dateFilter`). This can cause the active cell to lose focus since it's being re-rendered.

These changes schedule the active cell to be re-focused in the cases where the view would be re-rendered.

Fixes #29265.

(cherry picked from commit e74065a)
DBowen33 pushed a commit to DBowen33/components that referenced this issue Jul 3, 2024
…rrent view (angular#29287)

When some calendar inputs change, we need to re-render the entire view (e.g. `minDate` or `dateFilter`). This can cause the active cell to lose focus since it's being re-rendered.

These changes schedule the active cell to be re-focused in the cases where the view would be re-rendered.

Fixes angular#29265.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/a11y area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants