-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Bug
When an overlay is opened, it is inserted into the overlay container at the end of the document body. While one can control the tab-focus, particularly through the use of a focus-trap, it is difficult to control the screen-reader focus order. This came up in #7787, which was fixed (but only for dialogs), by making the rest of the page aria-hidden.
What is the expected behavior?
There should be at least two types of ways to handle focus on overlays, exemplified by certain Material components:
- The "dialog" mode: A focus-trap is applied to the overlay, and the rest of the page is inaccessible while the overlay is displayed, with or without a screen reader.
- The "menu" mode: An overlay is opened "in-line" on the page. The user should be able to move into and out of the overlay as if the DOM were next to the overlay origin.
What is the current behavior?
Mode 1 was fixed for dialog in #9016, but isn't easily accessible to custom overlays. I could copy the code over, but it would be nicer if the overlay service had a means to handle it.
Mode 2 does not exist. If you shift focus backwards in a screen reader when a component like MatMenu creates an overlay, it brings you to the bottom of the page instead of to the flyout origin.
What are the steps to reproduce?
Focusing on Mode 2 on the menu component, look at the provided MatMenu demo in StackBlitz:
https://stackblitz.com/angular/qyybdrnxmyx with a screen reader. (I've tested this on Chrome with VoiceOver on macOS so far, but I expect this effects most).
- Click "Menu". The screen reader focus is moved to Item 1.
- Navigate back (ctrl+option+left). This moves to the menu itself (no problem there).
- Navigate back again. This moves focus to "Current build: ...." instead of the original Menu button. On a larger page, this problem will be made worse by all the other elements in between.
What is the use-case or motivation for changing an existing behavior?
Improved accessibility.
Is there anything else we should know?
This affects an internal Google product.