Edit File Modal Keyboard Trap
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- angular, bootstrap, typescript
調査の方向性
Start by locating the Angular upload-item and upload-person edit-file modal components described in the issue, and check related issue #5502 for context. Reproduce the focus behavior in Safari with UVA-only or Embargo selected, then inspect the modal’s existing focus and dismissal handling. Done means keyboard focus enters and stays within the open modal, returns to its trigger on close, the dialog has an accessible name, and Escape still closes it.
索引モデルが issue の本文から書いたものです。
説明
@lgeggleston
Issue reported by University of Virginia (UVA) Library’s Assessment, Communications, and User Experience (ACE) team as part of internal DSpace 9 accessibility audit.
Issue 1 of 2: Edit File Modal Keyboard Trap
Describe the bug
Specifically in Safari, when the modal opens, keyboard focus is not properly managed. Users can tab out of the modal into background content and cannot tab back in, creating a functional keyboard trap. It appears to happen when UVA only or Embargo are selected. This violates the required modal dialog behavior defined in WCAG: Users must be able to move focus into and out of components using only the keyboard. The modal currently allows focus to escape but not return. When the modal appears, focus must move into it and remain within it until dismissed, preserving logical interaction order. The modal container lacks an accessible name via aria-labelledby, which can cause AT/browser combinations to incorrectly handle dialog focus. This issue blocks users from interacting with or closing the modal using keyboard-only navigation, making the modal inoperable for many users. Also affects: 2.1.2 No Keyboard Trap (Level A), 2.4.3 Focus Order (Level A), 4.1.2 Name, Role, Value (Level A)
Page
Upload Item (Form)
WCAG Guideline
WCAG 2.1.1, 2.1.2, 2.4.3, and 4.1.2
To Reproduce
Relevant code
Start of code: \<ngb-modal-window role="dialog" tabindex="-1" aria-modal="true" class="d-block modal fade show"\>\<div role="document" class="modal-dialog modal-xl"\>\<div class="modal-content"\>
Expected behavior
Move focus into the modal when it opens: Focus has to move to the first meaningful control immediately when the modal appears. This is usually the close button, but can also be the first field. Trap focus inside the modal while it is open: Tab and Shift+Tab have to move only within the modal elements. The background content shouldn't receive focus. Ensure the modal has an accessible name Add an id to the title and reference it via aria-labelledby on the modal container Return focus to the button that opened the modal when it closes Retain the current functionality of closing modal by pressing Esc
Suggested fix / example code
Adding accessible name: \<ngb-modal-window role="dialog" aria-modal="true" aria-labelledby="edit-file-title" tabindex="-1"\> \<div class="modal-dialog modal-xl"\> \<div class="modal-content"\> \<div class="modal-header"\> \<h4 id="edit-file-title" class="modal-title"\>Edit file\</h4\> \<button type="button" class="btn-close" aria-label="Close"\>\</button\> \</div\> \<!-- modal body --\> \</div\>\</div\>\</ngb-modal-window\> Please note: the Javascript below are examples, but I didn't dive into the JS. The general functionality of what should be happening should hopefully be clear enough that you can make edits as needed. Move focus into modal when opened: // Called when opening the modal ngAfterViewInit() { const closeBtn = this.elementRef.nativeElement.querySelector('.btn-close'); (closeBtn || this.elementRef.nativeElement).focus();} Trap focus into modal: @HostListener('keydown', ['$event']) handleTabTrap(event: KeyboardEvent) { const focusableSelectors = [ 'button:not([disabled])', '[href]', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', '[tabindex]:not([tabindex="-1"])' ]; const modal = this.elementRef.nativeElement; const focusable = Array.from(modal.querySelectorAll(focusableSelectors)); const first = focusable[0]; const last = focusable[focusable.length - 1]; if (event.key === 'Tab') { // Shift + Tab if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus();} // Tab forward else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus();}}} Restore focus on close: // Before opening the modal storeTrigger(triggerElement: HTMLElement) { this.triggerEl = triggerElement;} // On modal close ngOnDestroy() { this.triggerEl?.focus();}
Issue 2 of 2: Edit File Modal Keyboard Trap
Describe the bug
Specifically in Safari, when the modal opens, keyboard focus is not properly managed. Users can tab out of the modal into background content and cannot tab back in, creating a functional keyboard trap. It appears to happen when UVA only or Embargo are selected. This violates the required modal dialog behavior defined in WCAG: Users must be able to move focus into and out of components using only the keyboard. The modal currently allows focus to escape but not return. When the modal appears, focus must move into it and remain within it until dismissed, preserving logical interaction order. The modal container lacks an accessible name via aria-labelledby, which can cause AT/browser combinations to incorrectly handle dialog focus. This issue blocks users from interacting with or closing the modal using keyboard-only navigation, making the modal inoperable for many users.
Page
Upload Person (Form)
WCAG Guideline
WCAG 2.1.1, 2.1.2, 2.4.3, 4.1.2
To Reproduce
Relevant code
Start of code snippet: \<ngb-modal-window role="dialog" tabindex="-1" aria-modal="true" class="d-block modal fade show"\>\<div role="document" class="modal-dialog modal-xl"\>\<div class="modal-content"\>\<ds-submission-section-upload-file-edit \_nghost-dspace-angular-c3076456883=""\>\<div \_ngcontent-dspace-angular-c3076456883=""\>\<div \_ngcontent-dspace-angular-c3076456883="" class="modal-header"\>\<h4 \_ngcontent-dspace-angular-c3076456883="" class="modal-title"\>Edit file\</h4\>\<button \_ngcontent-dspace-angular-c3076456883="" type="button" aria-label="Close" class="
Expected behavior
Move focus into the modal when it opens: Focus has to move to the first meaningful control immediately when the modal appears. This is usually the close button, but can also be the first field. Trap focus inside the modal while it is open: Tab and Shift+Tab have to move only within the modal elements. The background content shouldn't receive focus. Ensure the modal has an accessible name Add an id to the title and reference it via aria-labelledby on the modal container Return focus to the button that opened the modal when it closes Retain the current functionality of closing modal by pressing Esc
Suggested fix / example code
Adding accessible name: \<ngb-modal-window role="dialog" aria-modal="true" aria-labelledby="edit-file-title" tabindex="-1"\>\<div class="modal-dialog modal-xl"\>\<div class="modal-content"\>\<div class="modal-header"\>\<h4 id="edit-file-title" class="modal-title"\>Edit file\</h4\>\<button type="button" class="btn-close" aria-label="Close"\>\</button\>\</div\>\</div\> \</div\>\</ngb-modal-window\> Please note: the Javascript below are examples, but I didn't dive into the JS. The general functionality of what should be happening should hopefully be clear enough that you can make edits as needed. Move focus into modal when opened: // Called when opening the modal ngAfterViewInit() { const closeBtn = this.elementRef.nativeElement.querySelector('.btn-close'); (closeBtn || this.elementRef.nativeElement).focus();} Trap focus into modal: @HostListener('keydown', ['$event']) handleTabTrap(event: KeyboardEvent) { const focusableSelectors = [ 'button:not([disabled])', '[href]', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', '[tabindex]:not([tabindex="-1"])' ]; const modal = this.elementRef.nativeElement; const focusable = Array.from(modal.querySelectorAll(focusableSelectors)); const first = focusable[0]; const last = focusable[focusable.length - 1]; if (event.key === 'Tab') { // Shift + Tab if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); } // Tab forward else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); } }} Restore focus on close: // Before opening the modal storeTrigger(triggerElement: HTMLElement) { this.triggerEl = triggerElement;} // On modal close ngOnDestroy() { this.triggerEl?.focus();}
Related work
- 主要言語
- TypeScript
- スター
- 180
- フォーク
- 577
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 111
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DSpace/dspace-angular のほかの issue
-
affects: 10.x affects: 9.x bug component: submission Difficulty: Low help wanted ux
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
DSpace/dspace-angular#6412 ·
メンテナーはふだん 3 日以内に返信
-
accessibility affects: 10.x affects: 8.x affects: 9.x bug help wanted ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
DSpace/dspace-angular#6364 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Author browse links on item page open in a new tab, unlike other browse links対応中かも @jesielviana が 18 日前に担当しました。 オープンaffects: main bug component: Item low priority
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DSpace/dspace-angular#6268 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
Mathjax single dollar sign delimiter configuration causes unintentional math rendering in abstractsオープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
DSpace/dspace-angular#6263 ·
メンテナーはふだん 3 日以内に返信
-
UI spacing regression on ds-generic-item-page-field (extra spaces around metadata values) in v10.xオープンaffects: 10.x affects: main bug component: Item ux
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DSpace/dspace-angular#6254 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
DSpace/dspace-angular の issue をすべて見る
似ている issue
-
area: server priority: P3 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
appandflow/stim#4538 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Published Docker images lack the redis extra: HEADROOM_COMPRESS_SESSION_STORE stops startup対応中かも @AlessandroSpallina が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
headroomlabs-ai/headroom#4513 ·
メンテナーはふだん 1 日以内に返信
-
bug extension extension: obsidian platform: Windows
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
raycast/extensions#32838 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
copy design-review mac P3
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
tosunlab/hisarapp-core#510 ·
-
bug priority-medium to-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信