From c4722ae8841f602fbf3f63433aa9512c82d5a1df Mon Sep 17 00:00:00 2001 From: Joe Longendyke Date: Sat, 18 Dec 2021 12:19:43 +0900 Subject: [PATCH] Automatically clear search bar In favor of #234 --- client/src/components/SearchBar/SearchBar.tsx | 1 + .../Settings/SearchSettings/SearchSettings.tsx | 13 +++++++++++++ client/src/interfaces/Config.ts | 1 + client/src/interfaces/Forms.ts | 1 + .../src/utility/templateObjects/configTemplate.ts | 1 + .../src/utility/templateObjects/settingsTemplate.ts | 1 + 6 files changed, 18 insertions(+) diff --git a/client/src/components/SearchBar/SearchBar.tsx b/client/src/components/SearchBar/SearchBar.tsx index 9920073..f35f4e3 100644 --- a/client/src/components/SearchBar/SearchBar.tsx +++ b/client/src/components/SearchBar/SearchBar.tsx @@ -105,6 +105,7 @@ export const SearchBar = (props: Props): JSX.Element => { const url = `${query.template}${search}`; redirectUrl(url, sameTab); } + if(config.autoClearSearch) clearSearch(); } else if (e.code === 'Escape') { clearSearch(); } diff --git a/client/src/components/Settings/SearchSettings/SearchSettings.tsx b/client/src/components/Settings/SearchSettings/SearchSettings.tsx index 9b057f5..652f9a0 100644 --- a/client/src/components/Settings/SearchSettings/SearchSettings.tsx +++ b/client/src/components/Settings/SearchSettings/SearchSettings.tsx @@ -130,6 +130,19 @@ export const SearchSettings = (): JSX.Element => { + + + + + diff --git a/client/src/interfaces/Config.ts b/client/src/interfaces/Config.ts index cab413f..cafdb02 100644 --- a/client/src/interfaces/Config.ts +++ b/client/src/interfaces/Config.ts @@ -17,6 +17,7 @@ export interface Config { hideCategories: boolean; hideSearch: boolean; defaultSearchProvider: string; + autoClearSearch: boolean; dockerApps: boolean; dockerHost: string; kubernetesApps: boolean; diff --git a/client/src/interfaces/Forms.ts b/client/src/interfaces/Forms.ts index ad3763f..2897c1b 100644 --- a/client/src/interfaces/Forms.ts +++ b/client/src/interfaces/Forms.ts @@ -13,6 +13,7 @@ export interface SearchForm { defaultSearchProvider: string; searchSameTab: boolean; disableAutofocus: boolean; + autoClearSearch: boolean; } export interface OtherSettingsForm { diff --git a/client/src/utility/templateObjects/configTemplate.ts b/client/src/utility/templateObjects/configTemplate.ts index 8d58153..ef7a71a 100644 --- a/client/src/utility/templateObjects/configTemplate.ts +++ b/client/src/utility/templateObjects/configTemplate.ts @@ -17,6 +17,7 @@ export const configTemplate: Config = { hideCategories: false, hideSearch: false, defaultSearchProvider: 'l', + autoClearSearch: false, dockerApps: false, dockerHost: 'localhost', kubernetesApps: false, diff --git a/client/src/utility/templateObjects/settingsTemplate.ts b/client/src/utility/templateObjects/settingsTemplate.ts index a122830..69cea61 100644 --- a/client/src/utility/templateObjects/settingsTemplate.ts +++ b/client/src/utility/templateObjects/settingsTemplate.ts @@ -38,6 +38,7 @@ export const searchSettingsTemplate: SearchForm = { searchSameTab: false, defaultSearchProvider: 'l', disableAutofocus: false, + autoClearSearch: false, }; export const dockerSettingsTemplate: DockerSettingsForm = {