From: Alexander Ebert Date: Mon, 29 May 2023 12:41:52 +0000 (+0200) Subject: Suppress errors when the query for search suggestion fail X-Git-Tag: 6.0.0_Alpha_1~65 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fcd4561dcfce545ab0bda1a95f9a11419b0d5767;p=GitHub%2FWoltLab%2FWCF.git Suppress errors when the query for search suggestion fail See https://www.woltlab.com/community/thread/299875-suppress-errors-if-requests-for-search-suggestions-fail/ --- diff --git a/ts/WoltLabSuite/Core/Ui/Search/Data.ts b/ts/WoltLabSuite/Core/Ui/Search/Data.ts index 11f0890e50..587b68a08f 100644 --- a/ts/WoltLabSuite/Core/Ui/Search/Data.ts +++ b/ts/WoltLabSuite/Core/Ui/Search/Data.ts @@ -18,4 +18,5 @@ export interface SearchInputOptions { minLength?: number; noResultPlaceholder?: string; preventSubmit?: boolean; + suppressErrors?: boolean; } diff --git a/ts/WoltLabSuite/Core/Ui/Search/Input.ts b/ts/WoltLabSuite/Core/Ui/Search/Input.ts index 09b1e1a81b..ea16ceb5df 100644 --- a/ts/WoltLabSuite/Core/Ui/Search/Input.ts +++ b/ts/WoltLabSuite/Core/Ui/Search/Input.ts @@ -30,6 +30,7 @@ class UiSearchInput { private readonly noResultPlaceholder: string; private readonly preventSubmit: boolean; private request?: AjaxRequest = undefined; + private readonly suppressErrors: boolean; private timerDelay?: number = undefined; /** @@ -61,6 +62,7 @@ class UiSearchInput { minLength: 3, noResultPlaceholder: "", preventSubmit: false, + suppressErrors: false, }, options, ) as SearchInputOptions; @@ -76,6 +78,7 @@ class UiSearchInput { this.minLength = options.minLength!; this.noResultPlaceholder = options.noResultPlaceholder!; this.preventSubmit = options.preventSubmit!; + this.suppressErrors = options.suppressErrors || false; // Disable auto-complete because it collides with the suggestion dropdown. this.element.autocomplete = "off"; @@ -359,6 +362,7 @@ class UiSearchInput { _ajaxSetup(): ReturnType { return { data: this.ajaxPayload, + silent: this.suppressErrors, }; } } diff --git a/ts/WoltLabSuite/Core/Ui/Search/Page.ts b/ts/WoltLabSuite/Core/Ui/Search/Page.ts index 7c9dc4863e..712a48fdbb 100644 --- a/ts/WoltLabSuite/Core/Ui/Search/Page.ts +++ b/ts/WoltLabSuite/Core/Ui/Search/Page.ts @@ -82,6 +82,7 @@ export function init(objectType: string): void { return true; }, + suppressErrors: true, }); const searchType = document.querySelector(".pageHeaderSearchType") as HTMLElement; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js index e8cf9d7527..5ee13784b6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js @@ -27,6 +27,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut noResultPlaceholder; preventSubmit; request = undefined; + suppressErrors; timerDelay = undefined; /** * Initializes the search input field. @@ -56,6 +57,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut minLength: 3, noResultPlaceholder: "", preventSubmit: false, + suppressErrors: false, }, options); this.ajaxPayload = options.ajax; this.autoFocus = options.autoFocus; @@ -68,6 +70,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut this.minLength = options.minLength; this.noResultPlaceholder = options.noResultPlaceholder; this.preventSubmit = options.preventSubmit; + this.suppressErrors = options.suppressErrors || false; // Disable auto-complete because it collides with the suggestion dropdown. this.element.autocomplete = "off"; this.element.addEventListener("keydown", (ev) => this.keydown(ev)); @@ -306,6 +309,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut _ajaxSetup() { return { data: this.ajaxPayload, + silent: this.suppressErrors, }; } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Page.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Page.js index 25a613cfce..15c19f0c4f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Page.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Page.js @@ -66,6 +66,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Dom/Util", "../Dropd }, 1); return true; }, + suppressErrors: true, }); const searchType = document.querySelector(".pageHeaderSearchType"); const dropdownMenu = Simple_1.default.getDropdownMenu(Util_1.default.identify(searchType));