angular / angular/components

bug(mat-select): lose the focus when no selection is made by pressing ESC

Offen
#30,632 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/select P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

15

### Description

When the mat-select is expanded, if user tries to close it with the "ESC" key without making a selection, the focus is lost and goes at the bottom of the page.

Tested in desktop environment with all major browsers and screen-readers.

### Reproduction

Example with the Angular latest version: [](https://next.material.angular.io/components/select/overview)
Steps to reproduce:
For example with NVDA:
- make sure that NVDA is not in the "browse mode"
- using arrow keys, put the NVDA keyboard focus on the select (for example from the Angular Material's documentation: "Favorite food", you hear "clickable Favorite food combo box collapsed opens list"). Tip: in "browse mode" you can use the "C" key to jump to the next combo box in the page
- make NVDA interact with the select ("focus mode") by pressing "ENTER" key or with the "FORCED FOCUS MODE" key (NVDA + space). You should hear a sound and NVDA speech again "Favorite food combo box collapsed opens list"
- press again enter to expand the select panel to show all possible options
- optionally, scroll options with down and up arrow keys
- do not select any option and press the "ESC" key. You should hear a "descending" sound that means the NVDA "focus mode" was deactivated and you are now in "browse mode" again
- using the up and down arrow keys to explore the page, you can see that the NVDA focus was moved down at the bottom of the page (at least for the NVDA virtual dom) and the select is still opened.

### Expected Behavior

For reference take the native example where the select should collapse when pressing the "ESC" key and the screen-reader focus remains on the select element.

Notice that in Angular Material v14 or v15, the correct behavior is the following:
while the select is open and the screen-reader is in the focus mode, if you press the "ESC" key one time the select closes but the focus mode not. Afther that, if you press "ESC" again the NVDA focus mode will deactivate and the focus will be placed where it was before you started the interaction.

### Actual Behavior

Same as Reproduction

### Environment

- Angular: 16>
- CDK/Material: Material
- Browser(s): Chrome and Firefox (latest)
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der im Issue verlinkten Angular Material select-Reproduktion und vergleiche ihr Verhalten bei der Escape-Taste mit Angular Material v14 oder v15 und dem nativen select-Beispiel. Die Behebung ist abgeschlossen, wenn das Drücken der Escape-Taste ohne Auswahl das select einklappt und der Screenreader-Fokus darauf bleibt, wobei der nächste Druck auf Escape den Fokus wie erwartet zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
accessibility, frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.