Update the `aria-expanded` attribute when implicitly closing drop-down menus
authorAlexander Ebert <ebert@woltlab.com>
Fri, 4 Aug 2023 11:32:02 +0000 (13:32 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 4 Aug 2023 11:32:02 +0000 (13:32 +0200)
Fixes #5553

ts/WoltLabSuite/Core/Ui/Dropdown/Simple.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js

index 41e94ad8297a40460b584ddbca69aa9d526c5805..77fab99ff3e7002b474d6ab6fba6e42bbd8a252b 100644 (file)
@@ -605,6 +605,11 @@ const UiDropdownSimple = {
         dropdown.classList.remove("dropdownOpen");
         _menus.get(containerId)!.classList.remove("dropdownOpen");
 
+        const button = dropdown.querySelector<HTMLElement>(".dropdownToggle");
+        if (button) {
+          button.setAttribute("aria-expanded", "false");
+        }
+
         notifyCallbacks(containerId, "close");
       }
     });
index 6baafd662df9cf92a198a2352984d382743bff25..51dc008c730ef2897c26ddfeac2f68739f44370c 100644 (file)
@@ -503,6 +503,10 @@ define(["require", "exports", "tslib", "../../CallbackList", "../../Core", "../.
                 if (dropdown.classList.contains("dropdownOpen")) {
                     dropdown.classList.remove("dropdownOpen");
                     _menus.get(containerId).classList.remove("dropdownOpen");
+                    const button = dropdown.querySelector(".dropdownToggle");
+                    if (button) {
+                        button.setAttribute("aria-expanded", "false");
+                    }
                     notifyCallbacks(containerId, "close");
                 }
             });