From f2aef6c115bb77800d18fa68444686ede48ecc8b Mon Sep 17 00:00:00 2001 From: Behrokh Satarnejad Date: Tue, 5 Nov 2024 09:24:40 +0100 Subject: [PATCH] set focus on first element of menu --- .../src/app/core/main-menu/main-menu-toggle.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts b/frontend/src/app/core/main-menu/main-menu-toggle.service.ts index 168344aa9a61..a8b110fdf35d 100644 --- a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts +++ b/frontend/src/app/core/main-menu/main-menu-toggle.service.ts @@ -132,9 +132,14 @@ export class MainMenuToggleService { } else { this.openMenu(); } - // Save the collapsed state in localStorage window.OpenProject.guardedLocalStorage(this.localStorageStateKey, String(!this.showNavigation)); + // Set focus on first visible main menu item. + // This needs to be called after AngularJS has rendered the menu, which happens some when after(!) we leave this + // method here. So we need to set the focus after a timeout. + setTimeout(() => { + jQuery('#main-menu [class*="-menu-item"]:visible').first().focus(); + }, 500); } public closeMenu():void {