Skip to content

mat-menu is acting differently when triggered via keyboard vs mouse #9252

Closed
@mertdeg2

Description

@mertdeg2

Bug, feature request, or proposal:

Bug

What is the expected behavior?

User clicks on the mat-menu trigger button, and first item within menu (or the entire menu) is focused.

What is the current behavior?

User clicks on the mat-menu trigger button, the button stays focused. This creates couple of accessibility issues. Note that if its triggered via keyboard this issue doesn't repro thanks to this logic: https://github.com/angular/material2/blob/3728555c6e37dbeb1756366c797c99655d8ffa1f/src/lib/menu/menu-trigger.ts#L240

What are the steps to reproduce?

  1. Go to https://stackblitz.com/angular/lrpbkepagev?file=app%2Fmenu-overview-example.html
  2. Click on the menu button
  3. Note that focus stays on the button (print document.activeElement)

Note that if you do this via keyboard, the first focusable element within mat-menu is focused.

What is the use-case or motivation for changing an existing behavior?

We have a tooltip component that stays open when a button is focused. When there is a tooltip and a menu attached to a component, click on the menu trigger button will result in both tooltip and menu showing. Once user clicks on menu, the menu component should take away to focus (like it does when its triggered via keyboard). This would also make sure screen readers announce the right content.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

All

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)GThis is is related to a Google internal issueP2The issue is important to a large percentage of users, with a workaround

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions