Skip to content

bug(sidenav/drawer/focustrap): over/push mode do not remove tabindex="0" when drawer closed #29545

@krzysztofpiotrow

Description

@krzysztofpiotrow

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

15

Description

When using mat-sidenav or mat-drawer with mode over or push (and might need backdrop=true) there is a div element:
<div class="cdk-visually-hidden cdk-focus-trap-anchor" aria-hidden="true"></div>
which always has tabindex="0" added to it but should get it only when the sidenav/drawer is opened.
As a result tabbing through the page is confusing.

Reproduction

StackBlitz link: https://stackblitz.com/edit/e4bsuu?file=package.json
StackBlitz was forked from the second example here: SideNav Examples
Steps to reproduce:

  1. Select Sidenav mode: Over, Has backdrop
  2. Via DevTools check that the mentioned elements have tabindex="0".

Expected Behavior

tabindex="0" is only added when the sidenav/drawer is opened.

Actual Behavior

tabindex="0" is always there and makes tabbing through the page confusing.

Environment

Angular: 16.1.1
CDK/Material: 16.2.0
Browser(s): Chrome
Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)P2The issue is important to a large percentage of users, with a workaroundarea: material/sidenav

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions