components icon indicating copy to clipboard operation
components copied to clipboard

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

Open richarddesan opened this issue 2 months ago • 4 comments

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: <mat-tree-node.mat-tree-node cdk-tree-node cdk-drag name-avg_p1 type-group ng-star-inserted mat-tree-node-selected> Ancestor with aria-hidden: <tsea-root ng-version=​"20.2.4" aria-hidden=​"true">​…​

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

richarddesan avatar Sep 25 '25 14:09 richarddesan

Duplicate of https://github.com/angular/components/issues/29578.

crisbeto avatar Sep 26 '25 04:09 crisbeto

@crisbeto are you sure this is a duplicate? Because in my stackblitz example it is not possible to get focus to the dialog so tabs are not working correctly

richarddesan avatar Sep 29 '25 09:09 richarddesan

Ah I misunderstood it. Reopening.

crisbeto avatar Sep 29 '25 09:09 crisbeto

FYI, same thing is happening on programmatic change of tab in mat-tab-group: setup a button to change tab with selectedIndex, warning Blocked aria-hidden... shows up

Reproduction: https://vtrmsett.stackblitz.io

ymongo avatar Nov 14 '25 11:11 ymongo