angular / angular/components

bug(CDK Dialog): aria-hidden is not removed when a child dialog is opened before but closed after a parent dialog.

未关闭
#30,028 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/dialog P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

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

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

_No response_

### Description

When an application uses routing, the application has its CDK `Dialog` instance (A), and the route's component has its own CDK `Dialog` instance (B), which has A as its parent.

When B opens a component in an overlay, it sets the **aria-hidden** attributes.

When the application provides a set of shared dialog components and a service to open them, they are opened from A, and **aria-hidden** attributes are not set because they are already present. (see [Dialog._hideNonDialogContentFromAssistiveTechnology](https://github.com/angular/components/blob/ef9cff380771da821fbf018b0e58ed4c0600b355/src/cdk/dialog/dialog.ts#L375C11-L375C55)).

When B removes the last dialog (see [Dialog._removeOpenDialog](https://github.com/angular/components/blob/ef9cff380771da821fbf018b0e58ed4c0600b355/src/cdk/dialog/dialog.ts#L348)) while its parent (A) has dialogs open, the aria-hidden attributes are not removed.

This means that because the parent CDK dialog (A) doesn't know that the child dialog had any attributes set, the **aria-hidden** attributes are never removed again, and the application becomes inaccessible to assistive technologies.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-starter-aa1qpb
Steps to reproduce:
1. Click on Load Child
2. Click on Show Dialog
3. In the dialog click 'save and close'
4. observe the 'wait dialog' being opened (before the Dialog is closed)
5. the dialog is closed
6. after the wait dialog is closed check the

### Expected Behavior

All **aria-hidden** attributes **set** by dialogs are removed again.

### Actual Behavior

The aria-hidden attributes set by CDK `Dialog` B remain.

### Environment

- Angular: 18.2.8
- CDK/Material: 18.2.8
- Browser(s): Any
- Operating System (e.g. Windows, macOS, Ubuntu): Any

贡献指南

打开贡献指南

调研方向

从 src/cdk/dialog/dialog.ts 中的 _hideNonDialogContentFromAssistiveTechnology 和 _removeOpenDialog 开始,按照复现中描述的父 Dialog 和子 Dialog 流程进行跟踪。复现链接的 StackBlitz 中的 routing 场景,然后验证两个 Dialog 都关闭后,子 Dialog 设置的 aria-hidden 属性会被移除。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
accessibility, frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。