Skip to content

fix(material/sidenav): only trap focus when backdrop is enabled #27355

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

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

zarend
Copy link
Contributor

@zarend zarend commented Jun 23, 2023

Correct when Sidenav enabled focus trapping. When backdrop is show, trap focus. Do no trap focus when backdrop is not shown.

Existing behavior is that Sidenav traps focus whenever it is not in side mode. This causes the end user to not be able to interact with the sidenav content when the mode is push/over, backdrop is disabled and using ConfigurableFocusTrapFactory (#26572).

With this commit applied, Sidenav always traps focus when backdrop is shown. Sidenav never traps focus when backdrop is not shown, regardless of what mode the sidenav is in, focus trapping will respect if the backdrop is shown or not shown.

Fix this issue by correcting boolean logic for detecting if backdrop is enabled and using that logic to determine when to trap focus. Add an example that injects ConfigurableFocusTrapFactory.

Fix #26572

@zarend zarend added Accessibility This issue is related to accessibility (a11y) target: minor This PR is targeted for the next minor release area: material/sidenav dev-app preview When applied, previews of the dev-app are deployed to Firebase labels Jun 23, 2023
@github-actions
Copy link

github-actions bot commented Jun 23, 2023

Deployed dev-app for 3a14e0c to: https://ng-dev-previews-comp--pr-angular-components-27355-1blrdk3z.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zarend zarend force-pushed the sidenav-focus-trap branch from 933fde4 to 48cb8d1 Compare June 27, 2023 22:35
@zarend
Copy link
Contributor Author

zarend commented Jun 27, 2023

Since this was last reviewed: fixed issue with showing backdrop when there are both a start and end sidenav. Add _drawerHasBackdrop method to simplify logic.

Correct when Sidenav enabled focus trapping. When backdrop is show, trap
focus. Do no trap focus when backdrop is not shown.

Existing behavior is that Sidenav traps focus whenever it is not in side
mode. This causes the end user to not be able to interact with the
sidenav content when the mode is push/over, backdrop is disabled and
using ConfigurableFocusTrapFactory (angular#26572).

With this commit applied, Sidenav always traps focus when backdrop is
shown. Sidenav never traps focus when backdrop is not shown, regardless
of what mode the sidenav is in, focus trapping will respect if the
backdrop is shown or not shown.

Fix this issue by correcting boolean logic for detecting if backdrop is
enabled and using that logic to determine when to trap focus. Add an
example that injects ConfigurableFocusTrapFactory.

Fix angular#26572
@zarend zarend force-pushed the sidenav-focus-trap branch from 48cb8d1 to 3a14e0c Compare June 27, 2023 22:40
@zarend zarend added the action: merge The PR is ready for merge by the caretaker label Jun 29, 2023
@zarend zarend merged commit daa6ca3 into angular:main Jul 6, 2023
@zarend zarend deleted the sidenav-focus-trap branch July 6, 2023 03:15
stephenrca pushed a commit to stephenrca/components that referenced this pull request Aug 2, 2023
…lar#27355)

Correct when Sidenav enabled focus trapping. When backdrop is show, trap
focus. Do no trap focus when backdrop is not shown.

Existing behavior is that Sidenav traps focus whenever it is not in side
mode. This causes the end user to not be able to interact with the
sidenav content when the mode is push/over, backdrop is disabled and
using ConfigurableFocusTrapFactory (angular#26572).

With this commit applied, Sidenav always traps focus when backdrop is
shown. Sidenav never traps focus when backdrop is not shown, regardless
of what mode the sidenav is in, focus trapping will respect if the
backdrop is shown or not shown.

Fix this issue by correcting boolean logic for detecting if backdrop is
enabled and using that logic to determine when to trap focus. Add an
example that injects ConfigurableFocusTrapFactory.

Fix angular#26572
@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 Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker area: material/sidenav dev-app preview When applied, previews of the dev-app are deployed to Firebase target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(mat-sidenav): There is no focus trap when Sidenav position is 'end'
3 participants