OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add some accessibility attributes to context menus
Christophe Bliard8177cce8f165
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex ad27e8e0dd8..20b0cf25285 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -566,6 +566,7 @@ en:label_watcher_added_successfully: "Watcher successfully added!"label_watcher_deleted_successfully: "Watcher successfully deleted!"label_work_package_details_you_are_here: "You are on the %{tab} tab for %{type} %{subject}."+ label_work_package_context_menu: "Work package context menu"label_unwatch: "Unwatch"label_unwatch_work_package: "Unwatch work package"label_uploaded_by: "Uploaded by"diff --git a/frontend/src/app/shared/components/op-context-menu/op-context-menu.html b/frontend/src/app/shared/components/op-context-menu/op-context-menu.htmlindex c3ae85a5cdc..34b2fb6b46e 100644--- a/frontend/src/app/shared/components/op-context-menu/op-context-menu.html+++ b/frontend/src/app/shared/components/op-context-menu/op-context-menu.html@@ -3,13 +3,15 @@ng-class="{'dropdown-anchor-right': locals.showAnchorRight}"><ul class="dropdown-menu "role="menu"+ [attr.aria-label]="locals.label"[ngClass]="{'-empty': items.length === 0 }"><ng-container *ngFor="let item of items">- <li *ngIf="item.divider" class="dropdown-divider"></li>+ <li *ngIf="item.divider" class="dropdown-divider" role="separator"></li><li *ngIf="!item.divider"><a*ngIf="item.href"class="menu-item"+ role="menuitem"[ngClass]="item.class"[class.inactive]="item.disabled"[attr.href]="item.href"@@ -27,6 +29,7 @@<button*ngIf="!item.href"class="menu-item"+ role="menuitem"[ngClass]="item.class"[class.inactive]="item.disabled"[attr.aria-disabled]="item.disabled"diff --git a/frontend/src/app/shared/components/op-context-menu/op-context-menu.types.ts b/frontend/src/app/shared/components/op-context-menu/op-context-menu.types.tsindex eae70a6d992..17f42c82b6d 100644--- a/frontend/src/app/shared/components/op-context-menu/op-context-menu.types.ts+++ b/frontend/src/app/shared/components/op-context-menu/op-context-menu.types.ts@@ -2,12 +2,6 @@ import { InjectionToken } from '@angular/core';export const OpContextMenuLocalsToken = new InjectionToken<any>('CONTEXT_MENU_LOCALS');-export interface OpContextMenuLocalsMap {- items:OpContextMenuItem[];- contextMenuId?:string;- [key:string]:any;-}-export interface OpContextMenuItem {disabled?:boolean;hidden?:boolean;@@ -20,3 +14,12 @@ export interface OpContextMenuItem {divider?:boolean;onClick?:($event:JQuery.TriggeredEvent|MouseEvent) => boolean;}++export interface OpContextMenuLocalsMap {+ items:OpContextMenuItem[];+ showAnchorRight?:boolean;+ contextMenuId?:string;+ label?:string;+ /* eslint-disable @typescript-eslint/no-explicit-any */+ [key:string]:any;+}diff --git a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.tsindex ffa2dec3f56..2ab580489ec 100644--- a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts+++ b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts@@ -59,17 +59,23 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {private copyToClipboardService:CopyToClipboardService;- constructor(public injector:Injector,+ constructor(+ public injector:Injector,protected workPackageId:string,protected $element:JQuery,protected additionalPositionArgs:any = {},- protected allowSplitScreenActions:boolean = true) {+ protected allowSplitScreenActions:boolean = true,+ ) {super(injector.get(OPContextMenuService));this.copyToClipboardService = injector.get(CopyToClipboardService);}public get locals():OpContextMenuLocalsMap {- return { contextMenuId: 'work-package-context-menu', items: this.items };+ return {+ contextMenuId: 'work-package-context-menu',+ label: I18n.t('js.label_work_package_context_menu'),+ items: this.items,+ };}public positionArgs(evt:JQuery.TriggeredEvent) {diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rbindex fd9f238613d..c2e036b4fd2 100644--- a/spec/features/work_packages/bulk/copy_work_package_spec.rb+++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb@@ -303,7 +303,7 @@ RSpec.describe 'Copy work packages through Rails view', :js, :with_cuprite doit 'does allow to copy' docontext_menu.open_for work_package- context_menu.expect_options ['Bulk copy']+ context_menu.expect_options 'Bulk copy'endend@@ -312,7 +312,8 @@ RSpec.describe 'Copy work packages through Rails view', :js, :with_cuprite doit 'does not allow to copy' docontext_menu.open_for work_package- context_menu.expect_no_options ['Bulk copy']+ $stop = true+ context_menu.expect_no_options 'Bulk copy'endendenddiff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rbindex 881fefb192e..c3bf0b8b312 100644--- a/spec/features/work_packages/bulk/move_work_package_spec.rb+++ b/spec/features/work_packages/bulk/move_work_package_spec.rb@@ -255,7 +255,7 @@ RSpec.describe 'Moving a work package through Rails view', :js docontext 'with permissions' doit 'does allow to move' docontext_menu.open_for work_package- context_menu.expect_options ['Bulk change of project']+ context_menu.expect_options 'Bulk change of project'endend@@ -264,7 +264,7 @@ RSpec.describe 'Moving a work package through Rails view', :js doit 'does not allow to move' docontext_menu.open_for work_package- context_menu.expect_no_options ['Bulk change of project']+ context_menu.expect_no_options 'Bulk change of project'endendenddiff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rbindex 0b5392c67cf..7d4c611e634 100644--- a/spec/features/work_packages/bulk/update_work_package_spec.rb+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb@@ -220,7 +220,7 @@ RSpec.describe 'Bulk update work packages through Rails view', :js, :with_cupritit 'does allow to edit' docontext_menu.open_for work_package- context_menu.expect_options ['Bulk edit']+ context_menu.expect_options 'Bulk edit'endcontext 'with a project budget' do@@ -243,7 +243,7 @@ RSpec.describe 'Bulk update work packages through Rails view', :js, :with_cupritit 'does not allow to edit' docontext_menu.open_for work_package- context_menu.expect_no_options ['Bulk edit']+ context_menu.expect_no_options 'Bulk edit'endendenddiff --git a/spec/features/work_packages/table/context_menu/context_menu_spec.rb b/spec/features/work_packages/table/context_menu/context_menu_spec.rbindex 472213a20b7..6fefc826a03 100644--- a/spec/features/work_packages/table/context_menu/context_menu_spec.rb+++ b/spec/features/work_packages/table/context_menu/context_menu_spec.rb@@ -39,7 +39,7 @@ RSpec.describe 'Work package table context menu', :js, :with_cuprite do# Open context menumenu.expect_closedmenu.open_for(work_package)- menu.expect_options ['Add predecessor', 'Add follower']+ menu.expect_options 'Add predecessor', 'Add follower'endcontext 'for multiple selected WPs' do@@ -57,8 +57,8 @@ RSpec.describe 'Work package table context menu', :js, :with_cuprite dofind('body').send_keys [:control, 'a']menu.open_for(work_package)- menu.expect_options ['Open details view', 'Open fullscreen view',- 'Bulk edit', 'Bulk copy', 'Bulk change of project', 'Bulk delete']+ menu.expect_options 'Open details view', 'Open fullscreen view',+ 'Bulk edit', 'Bulk copy', 'Bulk change of project', 'Bulk delete'endendenddiff --git a/spec/support/components/work_packages/context_menu.rb b/spec/support/components/work_packages/context_menu.rbindex a520e6965cc..58f5eaa2388 100644--- a/spec/support/components/work_packages/context_menu.rb+++ b/spec/support/components/work_packages/context_menu.rb@@ -61,15 +61,17 @@ module Componentsenddef expect_open- expect(page).to have_selector(selector)+ expect(page).to have_selector(:menu, work_package_context_menu_label)enddef expect_closed- expect(page).to have_no_selector(selector)+ expect(page).to have_no_selector(:menu, work_package_context_menu_label)enddef choose(target)- find("#{selector} .menu-item", text: target, exact_text: true).click+ within_menu do+ find(:menuitem, text: target, exact_text: true).click+ endenddef choose_delete_and_confirm_deletion@@ -83,22 +85,30 @@ module Componentsdef expect_no_options(*options)expect_open- options.each do |text|- expect(page).to have_no_css("#{selector} .menu-item", text:)+ within_menu do+ options.each do |text|+ expect(page).to have_no_selector(:menuitem, text:)+ endendend- def expect_options(options)+ def expect_options(*options)expect_open- options.each do |text|- expect(page).to have_css("#{selector} .menu-item", text:)+ within_menu do+ options.each do |text|+ expect(page).to have_selector(:menuitem, text:)+ endendendprivate- def selector- '#work-package-context-menu'+ def within_menu(&)+ within(:menu, work_package_context_menu_label, &)+ end++ def work_package_context_menu_label+ I18n.t('js.label_work_package_context_menu')endendenddiff --git a/spec/support/components/work_packages/hierarchies.rb b/spec/support/components/work_packages/hierarchies.rbindex 2dffe645368..1f9175abdab 100644--- a/spec/support/components/work_packages/hierarchies.rb+++ b/spec/support/components/work_packages/hierarchies.rb@@ -79,11 +79,11 @@ module Componentscontext_menu.open_for work_packageif indent- context_menu.expect_options ['Indent hierarchy']+ context_menu.expect_options 'Indent hierarchy'endif outdent- context_menu.expect_options ['Outdent hierarchy']+ context_menu.expect_options 'Outdent hierarchy'endenddiff --git a/spec/support/components/work_packages/settings_menu.rb b/spec/support/components/work_packages/settings_menu.rbindex 409201ef8da..924fedffdb9 100644--- a/spec/support/components/work_packages/settings_menu.rb+++ b/spec/support/components/work_packages/settings_menu.rb@@ -74,7 +74,7 @@ module Componentsfind("#{selector} .menu-item", text: target, match: :prefer_exact).clickend- def expect_options(options)+ def expect_options(*options)expect_openoptions.each do |text|expect(page).to have_css("#{selector} a", text:)