angular / angular/components

bug(MatDialog): Blocked aria-hidden on an element because its descendant retained focus

Aperta
#31,927 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Accessibility area: material/dialog P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

### 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

Angular: 18.2

### Description

This is a follow up of https://github.com/angular/components/issues/30187

That fix works, but not for dialogs in a tree view

const ok = await firstValueFrom(
this.matDialog.open(AddNodeDialogComponent, { data, maxHeight: '90vh', width: '650px', autoFocus: 'first-heading', restoreFocus: true }).afterClosed(),
);

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus:
Ancestor with aria-hidden: ​…​​

### Reproduction

StackBlitz link:
Steps to reproduce:
1. https://stackblitz.com/edit/rwbw9hex?file=src%2Fexample%2Ftree-dynamic-example.ts
2. Click on the + icon to open a dialog. The focus stays on the background

### Expected Behavior

Add focus to the dialog and don't show warning message

### Actual Behavior

Unable to set focus to dialog

### Environment

@angular-devkit/architect 0.2001.6
@angular-devkit/core 20.2.2
@angular-devkit/schematics 20.2.2
@schematics/angular 20.1.6

Chrome 140 Windows

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione StackBlitz collegata, in particolare src/example/tree-dynamic-example.ts, e traccia il comportamento del focus di MatDialog con il trigger mat-tree. Verifica come interagiscono autoFocus e restoreFocus quando si apre il dialog. Il lavoro è completato quando il focus si sposta nel dialog senza l’avviso aria-hidden e l’interazione con l’albero continua a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
accessibility, frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.