Skip to content

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

Clearly define which element in a drop modal shall be focused instead of just choosing the first possible element

Henriette Darge68ff5ef29efd
diff --git a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
index 82a5b431d2e..3065fda45d4 100644
--- a/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
+++ b/frontend/src/app/shared/components/autocompleter/project-menu-autocomplete/project-menu-autocomplete.template.html
@@ -36,6 +36,7 @@
[(ngModel)]="searchableProjectListService.searchText"
[ngModelOptions]="{standalone: true}"
data-qa-selector="op-project-menu-autocomplete--search"
+ data-list-focus-catcher-container="true"
>
<span
slot="before"
diff --git a/frontend/src/app/shared/components/project-include/project-include.component.html b/frontend/src/app/shared/components/project-include/project-include.component.html
index ff3b32d26c4..6fdd65e330a 100644
--- a/frontend/src/app/shared/components/project-include/project-include.component.html
+++ b/frontend/src/app/shared/components/project-include/project-include.component.html
@@ -39,6 +39,7 @@
[(ngModel)]="searchableProjectListService.searchText"
[ngModelOptions]="{standalone: true}"
data-qa-selector="project-include-search"
+ data-list-focus-catcher-container="true"
>
<span
slot="before"
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
index a7ff743dbe9..3e7383bb44c 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
@@ -39,8 +39,13 @@ export class SpotDropModalComponent implements OnDestroy {
document.body.addEventListener('click', this.closeEventListener);
document.body.addEventListener('keydown', this.escapeListener);
- // Index 1 because the element at index 0 is the trigger button to open the modal
- (findAllFocusableElementsWithin(this.elementRef.nativeElement)[1] as HTMLElement).focus();
+ const focusCatcherContainer = document.querySelectorAll("[data-list-focus-catcher-container='true']")[0];
+ if (focusCatcherContainer) {
+ (findAllFocusableElementsWithin(focusCatcherContainer as HTMLElement)[0] as HTMLElement).focus();
+ } else {
+ // Index 1 because the element at index 0 is the trigger button to open the modal
+ (findAllFocusableElementsWithin(this.elementRef.nativeElement)[1] as HTMLElement).focus();
+ }
});
} else {
document.body.removeEventListener('click', this.closeEventListener);