ionic-team / ionic-team/ionic-framework

bug: modal overlay not automatically focussed when ModalOption keyboardClose is false

未关闭
#28,775 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: bug
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

v7.6.2

### Current Behavior

For both the inline and controller-based modal, setting `keyboardClose` to false results in a lack of focus trapping inside the modal. Focus remains on the trigger element and subsequent tabs will traverse through the tabbable elements _behind_ the modal.

Furthermore this leads to applications needing to guard against accidentally instantiating multiple modals on top of each other when using the `ModalController`. Users might press enter/space repeatedly and unknowingly instantate many modals as they are not immediately discoverable.

### Expected Behavior

I expect to be able to immediately tab to the cancel button of the modal once the modal is opened, and cycle through only the elements inside the modal when tabbing.

### Steps to Reproduce

1. clone, install and serve: https://github.com/RasmusKjeldgaard/ionic-modal-keyboardClose-repro
- Alternatively [this stackblitz](https://stackblitz.com/edit/angular-vbyhpw?file=src%2Fapp%2Fexample.component.ts) with a minor tweak to the default docs example can be used for quick verification
2. tab to or click on the 'open' button so the modal opens
4. tab again and see that focus still behind the modal

### Code Reproduction URL

https://github.com/RasmusKjeldgaard/ionic-modal-keyboardClose-repro

### Ionic Info

Ionic:

Ionic CLI : 7.1.1 (/Users/rkjeldgaard/.nvm/versions/node/v18.13.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.6.2
@angular-devkit/build-angular : 17.0.8
@angular-devkit/schematics : 17.0.8
@angular/cli : 17.0.8
@ionic/angular-toolkit : 9.0.0

Capacitor:

Capacitor CLI : 5.6.0
@capacitor/android : not installed
@capacitor/core : 5.6.0
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 2.0.0

System:

NodeJS : v18.13.0 (/Users/rkjeldgaard/.nvm/versions/node/v18.13.0/bin/node)
npm : 8.19.3
OS : macOS Unknown

### Additional Information

_No response_

贡献指南

打开贡献指南

调研方向

Start with the linked reproduction repository or StackBlitz and verify the behavior for both inline and controller-based modals with keyboardClose set to false. Trace the modal focus handling and confirm that opening moves focus to the modal, while tabbing remains within its tabbable elements and reaches the cancel button.

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

评估

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

把新 issue 发到你的邮箱

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