From b32a1f5baefb15e7c0c25dde4b15100a32686205 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 24 May 2022 18:38:52 +0200 Subject: [PATCH] Improved behavior of the mobile search An already active overlay such as the mobile menu could cause the page to become scrollable. See https://www.woltlab.com/community/thread/295731-mobil-%C3%B6ffnen-der-suche-nach-%C3%B6ffnen-eines-men%C3%BCs-fehlerhaft/ --- ts/WoltLabSuite/Core/Ui/CloseOverlay.ts | 1 + ts/WoltLabSuite/Core/Ui/Search.ts | 6 ++++-- .../install/files/js/WoltLabSuite/Core/Ui/CloseOverlay.js | 1 + wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js | 7 +++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/CloseOverlay.ts b/ts/WoltLabSuite/Core/Ui/CloseOverlay.ts index 980022ed87..04ce4fd7d2 100644 --- a/ts/WoltLabSuite/Core/Ui/CloseOverlay.ts +++ b/ts/WoltLabSuite/Core/Ui/CloseOverlay.ts @@ -15,6 +15,7 @@ const _callbackList = new CallbackList(); export enum Origin { Document = "document", DropDown = "dropdown", + Search = "search", } type Callback = (origin?: string | Origin, identifier?: string) => void; diff --git a/ts/WoltLabSuite/Core/Ui/Search.ts b/ts/WoltLabSuite/Core/Ui/Search.ts index 4b57e78294..6c6c189529 100644 --- a/ts/WoltLabSuite/Core/Ui/Search.ts +++ b/ts/WoltLabSuite/Core/Ui/Search.ts @@ -57,7 +57,9 @@ function initSearchBar(): void { }); UiCloseOverlay.add("WoltLabSuite/Core/Ui/Search", (origin, identifier) => { - if (origin === Origin.DropDown) { + if (origin === Origin.Search) { + return; + } else if (origin === Origin.DropDown) { const button = document.getElementById("pageHeaderSearchTypeSelect")!; if (button.dataset.target === identifier) { return; @@ -124,7 +126,7 @@ function initMobileSearch(): void { } function openSearch(): void { - UiCloseOverlay.execute(); + UiCloseOverlay.execute(Origin.Search); _pageHeader.classList.add("searchBarOpen"); _userPanelSearchButton?.parentElement!.classList.add("open"); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/CloseOverlay.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/CloseOverlay.js index ff3eac2165..92344d36ce 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/CloseOverlay.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/CloseOverlay.js @@ -17,6 +17,7 @@ define(["require", "exports", "tslib", "../CallbackList"], function (require, ex (function (Origin) { Origin["Document"] = "document"; Origin["DropDown"] = "dropdown"; + Origin["Search"] = "search"; })(Origin = exports.Origin || (exports.Origin = {})); let hasGlobalListener = false; function add(identifier, callback) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js index dc16344f2b..d05b6d6fa2 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search.js @@ -52,7 +52,10 @@ define(["require", "exports", "tslib", "../Event/Handler", "./Alignment", "./Clo } }); CloseOverlay_1.default.add("WoltLabSuite/Core/Ui/Search", (origin, identifier) => { - if (origin === CloseOverlay_1.Origin.DropDown) { + if (origin === CloseOverlay_1.Origin.Search) { + return; + } + else if (origin === CloseOverlay_1.Origin.DropDown) { const button = document.getElementById("pageHeaderSearchTypeSelect"); if (button.dataset.target === identifier) { return; @@ -104,7 +107,7 @@ define(["require", "exports", "tslib", "../Event/Handler", "./Alignment", "./Clo }); } function openSearch() { - CloseOverlay_1.default.execute(); + CloseOverlay_1.default.execute(CloseOverlay_1.Origin.Search); _pageHeader.classList.add("searchBarOpen"); _userPanelSearchButton === null || _userPanelSearchButton === void 0 ? void 0 : _userPanelSearchButton.parentElement.classList.add("open"); if (!_isMobile) { -- 2.20.1