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(bottom-sheet): auto focus defaults to dialog instead of first-tabbable #30483

Closed
1 task
mlemoine-clgx opened this issue Feb 12, 2025 · 0 comments · Fixed by #30549
Closed
1 task

bug(bottom-sheet): auto focus defaults to dialog instead of first-tabbable #30483

mlemoine-clgx opened this issue Feb 12, 2025 · 0 comments · Fixed by #30549
Assignees
Labels
area: material/bottom-sheet P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@mlemoine-clgx
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

The documentation https://material.angular.io/components/bottom-sheet/overview#focus-management specifies that the default behavior for autoFocus is first-tabbable. However, since at least v16, the default behavior has been set to dialog.

This is a surprising autoFocus behavior from an accessibility standpoint.

This even seems to have been enshrined in the tests: https://github.com/angular/components/blob/c1ff40f/src/material/bottom-sheet/bottom-sheet.spec.ts#L620

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-starter-dd7tdtv9?file=src%2Fmain.ts
Steps to reproduce:

  1. BottomSheet opens on init
  2. Note that the element inside does not have focus. But it is tabbable

Expected Behavior

First tabbable element should receive focus

Actual Behavior

First tabbable element does not receive focus, bottom sheet container receives focus instead.

Environment

  • Angular: 18.2.8
  • CDK/Material: 18.2.8
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@mlemoine-clgx mlemoine-clgx added the needs triage This issue needs to be triaged by the team label Feb 12, 2025
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/bottom-sheet and removed needs triage This issue needs to be triaged by the team labels Feb 18, 2025
crisbeto added a commit to crisbeto/material2 that referenced this issue Feb 26, 2025
Switches the bottom sheet to focusing the first tabbale element by default like we do in `MatDialog`.

Note that we had a comment saying that the previous behavior was intentional. That seems to be a leftover from angular#14534 where the underlying cause was that we were delaying focus until the animation is done. We now have better ways of handling it so the comment isn't relevant anymore.

Fixes angular#30483.
@crisbeto crisbeto self-assigned this Feb 26, 2025
crisbeto added a commit that referenced this issue Feb 26, 2025
…30549)

Switches the bottom sheet to focusing the first tabbale element by default like we do in `MatDialog`.

Note that we had a comment saying that the previous behavior was intentional. That seems to be a leftover from #14534 where the underlying cause was that we were delaying focus until the animation is done. We now have better ways of handling it so the comment isn't relevant anymore.

Fixes #30483.
crisbeto added a commit that referenced this issue Feb 26, 2025
…30549)

Switches the bottom sheet to focusing the first tabbale element by default like we do in `MatDialog`.

Note that we had a comment saying that the previous behavior was intentional. That seems to be a leftover from #14534 where the underlying cause was that we were delaying focus until the animation is done. We now have better ways of handling it so the comment isn't relevant anymore.

Fixes #30483.

(cherry picked from commit ee5b13f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/bottom-sheet 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