Automatically clear search bar

In favor of #234
This commit is contained in:
Joe Longendyke 2021-12-18 12:19:43 +09:00
parent 6d8ce5361a
commit c4722ae884
No known key found for this signature in database
GPG key ID: A24E92202E5DEA61
6 changed files with 18 additions and 0 deletions

View file

@ -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();
}

View file

@ -130,6 +130,19 @@ export const SearchSettings = (): JSX.Element => {
</select>
</InputGroup>
<InputGroup>
<label htmlFor={"autoClearSearch"}>Automatically clear the search bar</label>
<select
id={"autoClearSearch"}
name={"autoClearSearch"}
value={formData.autoClearSearch ? 1 : 0}
onChange={(e) => inputChangeHandler(e, { isBool: true })}
>
<option value={1}>True</option>
<option value={0}>False</option>
</select>
</InputGroup>
<Button>Save changes</Button>
</form>

View file

@ -17,6 +17,7 @@ export interface Config {
hideCategories: boolean;
hideSearch: boolean;
defaultSearchProvider: string;
autoClearSearch: boolean;
dockerApps: boolean;
dockerHost: string;
kubernetesApps: boolean;

View file

@ -13,6 +13,7 @@ export interface SearchForm {
defaultSearchProvider: string;
searchSameTab: boolean;
disableAutofocus: boolean;
autoClearSearch: boolean;
}
export interface OtherSettingsForm {

View file

@ -17,6 +17,7 @@ export const configTemplate: Config = {
hideCategories: false,
hideSearch: false,
defaultSearchProvider: 'l',
autoClearSearch: false,
dockerApps: false,
dockerHost: 'localhost',
kubernetesApps: false,

View file

@ -38,6 +38,7 @@ export const searchSettingsTemplate: SearchForm = {
searchSameTab: false,
defaultSearchProvider: 'l',
disableAutofocus: false,
autoClearSearch: false,
};
export const dockerSettingsTemplate: DockerSettingsForm = {