Skip to content

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

Closed
@mlemoine-clgx

Description

@mlemoine-clgx

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/bottom-sheet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions