diff --git a/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts b/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts index 8f7053d6..a3d5239f 100644 --- a/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts +++ b/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts @@ -143,28 +143,32 @@ export class ProductFilterViewModel { const urlParams = new URL(document.location.href).searchParams; const urlSearch = urlParams.get("search")?.trim() ?? ""; - if (urlSearch) { - this.store.setSearchValue(urlSearch); - } - this.searchValue.value = this.store.currentSearchValue; - const urlRanges = urlParams .getAll("ranges[]") .map(v => Number.parseInt(v.trim(), 10)) .filter(v => !Number.isNaN(v)) as RangeId[]; - this.store.setActiveRanges(urlRanges); - const urlTags = urlParams .getAll("tags[]") .map(v => Number.parseInt(v.trim(), 10)) .filter(v => !Number.isNaN(v)) as TagId[]; - this.store.setActiveTags(urlTags); - const urlBrands = urlParams .getAll("brands[]") .map(v => v.trim()) .filter(v => v.length) as BrandValue[]; + + if (urlSearch.length) { + this.store.setSearchValue(urlSearch); + } + this.store.setActiveRanges(urlRanges); + this.store.setActiveTags(urlTags); this.store.setActiveBrands(urlBrands); + this.searchValue.value = this.store.currentSearchValue; + + if (urlSearch.length || urlRanges.length || urlTags.length || urlBrands.length) { + this.store.setLoading(true); + this.refreshList(); + } + watch(this.searchValue, (newValue) => { const cleanText = String(newValue || "");