angular / angular/components

mat-menu focuses the second item on Arrow Down when opened with the mouse

Ouverte
#16,184 4 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Accessibility area: material/menu needs: discussion P4
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

#### Bug, feature request, or proposal:
Bug

#### What is the expected behavior?
When opening a menu with the mouse, no items are focused. Pressing arrow down (on the keyboard) in this state (where no item is focused) would focus the first item; pressing arrow up would focus the last item (via wrapping around).

#### What is the current behavior?
Opening a menu with the mouse and then pressing arrow down focuses the second menu item.

#### What are the steps to reproduce?
1. Go to
* https://material.angular.io/components/menu/overview
* or https://v7.material.angular.io/components/menu/overview
* or https://v6.material.angular.io/components/menu/overview
2. Click on the "Menu" button in the basic menu example.
3. Press Down Arrow on the keyboard

Recording: [2019-06-02_19-34-41](https://user-images.githubusercontent.com/5409190/58768724-7d33ff80-856d-11e9-9496-452b95939d56.gif)

#### What is the use-case or motivation for changing an existing behavior?
The current behavior is non-intuitive: Nothing is visibility focused, but the menu behaves as if the first item is focused.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular Material 6.4.7, 7.3.7, and 8.0.0
Tested in Firefox and Chrome on Windows 10

#### Is there anything else we should know?
Root cause appears to be that there is always a menu item focused; but, the focused menu item when the menu is opened by the mouse is styled like a normal menu item, giving the impression there is no item focused by default.

This can be observed (at least for 8.0.0) by adding a style for `.cdk-focused.cdk-mouse-focused`, and observing that the style is applied to the first menu item when opening the menu with the mouse.

---

Potentially related issue: https://github.com/angular/components/issues/2657

That issue describes the behavior I see in 5.2.5 (here: https://v5.material.angular.io/components/menu/overview ), where opening the menu with the mouse disables focus styling (making keyboard navigation hard to use), but opening the menu with the keyboard allows for keyboard navigation (whereas now, the focus state is hidden until the user interacts with the keyboard). At the time, the issue was closed saying the behavior was intended.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire le comportement de l’exemple de menu de base dans Angular Material menu overview, en l’ouvrant avec la souris et en appuyant sur Arrow Down ou Arrow Up. Suivez la gestion du focus du menu et vérifiez qu’aucun élément n’est considéré comme ayant le focus après une ouverture avec la souris ; Arrow Down doit alors placer le focus sur le premier élément et Arrow Up sur le dernier.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
accessibility, frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
52/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.