Skip to content

Dialog focus restoration doesn't work on mat-menu-items #17962

@calebegg

Description

@calebegg

If you trigger a dialog from a mat-menu-item's click handler, the focused item is the mat-menu-item itself. This gets saved in _elementFocusedBeforeDialogWasOpened. But that element is gone from the DOM when the dialog is closed, so focus is restored to the body.

It would be cool if the dialog could somehow keep track of the fact that it was a transient menu item that was focused, and focus ought to go back to the menu's trigger instead.

Waiting a tick before opening the dialog fixes it, because the menu itself focuses the trigger before the dialog opens, so it gets the right element ref.

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)GThis is is related to a Google internal issueP3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/dialogarea: material/menu

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions