From cb3545a303c4f9213ad70b292e66adef1684a892 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:07:15 +1100 Subject: [PATCH] Clear search term when clicking popover pill (#3408) --- ui/v2.5/src/components/List/ListFilter.tsx | 7 +++++++ ui/v2.5/src/docs/en/Changelog/v0190.md | 1 + ui/v2.5/src/models/list-filter/filter.ts | 3 +++ 3 files changed, 11 insertions(+) diff --git a/ui/v2.5/src/components/List/ListFilter.tsx b/ui/v2.5/src/components/List/ListFilter.tsx index 9236a5561..51e1acd7d 100644 --- a/ui/v2.5/src/components/List/ListFilter.tsx +++ b/ui/v2.5/src/components/List/ListFilter.tsx @@ -91,6 +91,13 @@ export const ListFilter: React.FC = ({ } }, [customPageSizeShowing, perPageFocus]); + // clear search input when filter is cleared + useEffect(() => { + if (filter.searchTerm === "") { + queryRef.current.value = ""; + } + }, [filter.searchTerm, queryRef]); + function onChangePageSize(val: string) { if (val === "custom") { // added timeout since Firefox seems to trigger the rootClose immediately diff --git a/ui/v2.5/src/docs/en/Changelog/v0190.md b/ui/v2.5/src/docs/en/Changelog/v0190.md index 568050a3b..4b3c4b124 100644 --- a/ui/v2.5/src/docs/en/Changelog/v0190.md +++ b/ui/v2.5/src/docs/en/Changelog/v0190.md @@ -14,6 +14,7 @@ * Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113)) ### 🐛 Bug fixes +* Fixed clicking popover pills not clearing search term. ([#3408](https://github.com/stashapp/stash/pull/3408)) * Fixed URL not being preserved when redirected to login. ([#3305](https://github.com/stashapp/stash/pull/3305)) * Fixed scene previews not being overwritten when Overwrite option is selected. ([#3256](https://github.com/stashapp/stash/pull/3256)) * Fixed objects without titles not being sorted correctly with objects with titles. ([#3244](https://github.com/stashapp/stash/pull/3244)) diff --git a/ui/v2.5/src/models/list-filter/filter.ts b/ui/v2.5/src/models/list-filter/filter.ts index 0a938eb07..c25205293 100644 --- a/ui/v2.5/src/models/list-filter/filter.ts +++ b/ui/v2.5/src/models/list-filter/filter.ts @@ -93,6 +93,9 @@ export class ListFilterModel { } if (params.q) { this.searchTerm = params.q.trim(); + } else { + // #1795 - reset search term if not provided + this.searchTerm = ""; } this.currentPage = params.p ? Number.parseInt(params.p, 10) : 1; if (params.perPage) this.itemsPerPage = Number.parseInt(params.perPage, 10);