Restore the mobile search icon when closing the search
authorAlexander Ebert <ebert@woltlab.com>
Tue, 18 Jul 2023 13:38:18 +0000 (15:38 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 18 Jul 2023 13:38:18 +0000 (15:38 +0200)
See https://www.woltlab.com/community/thread/300653-mobiles-such-icon-%C3%A4ndert-seinen-status-nicht/

ts/WoltLabSuite/Core/Ui/Search.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js

index 8934b0148ac6d5cafa8c1ac9ea661a56bf51f6b7..ae55b5fe43d723964816cfc325795261f2e519a6 100644 (file)
@@ -86,9 +86,6 @@ function initMobileSearch(): void {
 
     if (searchButton.getAttribute("aria-expanded") === "true") {
       closeSearch();
-
-      searchButton.setAttribute("aria-expanded", "false");
-      searchButton.querySelector("fa-icon")!.setIcon("magnifying-glass");
     } else {
       // iOS Safari behaves unpredictable when the keyboard focus
       // is moved into a HTML element that is inside a parent with
@@ -120,9 +117,6 @@ function initMobileSearch(): void {
       event.preventDefault();
 
       closeSearch();
-
-      searchButton.setAttribute("aria-expanded", "false");
-      searchButton.querySelector("fa-icon")!.setIcon("magnifying-glass");
     }
   });
 }
@@ -179,6 +173,12 @@ function closeSearch(): void {
     _pageHeaderSearchInput.blur();
   }
 
+  const searchButton = document.getElementById("pageHeaderSearchMobile");
+  if (searchButton) {
+    searchButton.setAttribute("aria-expanded", "false");
+    searchButton.querySelector("fa-icon")!.setIcon("magnifying-glass");
+  }
+
   const scope = _pageHeaderSearch.querySelector(".pageHeaderSearchType")!;
   UiDropdownSimple.close(scope.id);
 }
index 15a4e29f39cbe572dd31ed2abc4c99475e2d2e97..b8b364d662a25b0d53a91e25c3067927e0eb70a1 100644 (file)
@@ -76,8 +76,6 @@ define(["require", "exports", "tslib", "../Event/Handler", "./Alignment", "./Clo
             event.stopPropagation();
             if (searchButton.getAttribute("aria-expanded") === "true") {
                 closeSearch();
-                searchButton.setAttribute("aria-expanded", "false");
-                searchButton.querySelector("fa-icon").setIcon("magnifying-glass");
             }
             else {
                 // iOS Safari behaves unpredictable when the keyboard focus
@@ -103,8 +101,6 @@ define(["require", "exports", "tslib", "../Event/Handler", "./Alignment", "./Clo
             if (event.target === _pageHeaderSearch) {
                 event.preventDefault();
                 closeSearch();
-                searchButton.setAttribute("aria-expanded", "false");
-                searchButton.querySelector("fa-icon").setIcon("magnifying-glass");
             }
         });
     }
@@ -149,6 +145,11 @@ define(["require", "exports", "tslib", "../Event/Handler", "./Alignment", "./Clo
         if (_isMobile) {
             _pageHeaderSearchInput.blur();
         }
+        const searchButton = document.getElementById("pageHeaderSearchMobile");
+        if (searchButton) {
+            searchButton.setAttribute("aria-expanded", "false");
+            searchButton.querySelector("fa-icon").setIcon("magnifying-glass");
+        }
         const scope = _pageHeaderSearch.querySelector(".pageHeaderSearchType");
         Simple_1.default.close(scope.id);
     }