Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/hooks/useProductListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function useProductListing({
[fetchProducts],
);

// Fetch filters
// Fetch filters (scoped to search query when present)
useEffect(() => {
if (storeLoading) return;

Expand All @@ -97,7 +97,11 @@ export function useProductListing({
const fetchFilters = async () => {
setFiltersLoading(true);
try {
const response = await getProductFilters(filterParams, {
const params = { ...filterParams };
if (searchQuery) {
params["q[multi_search]"] = searchQuery;
}
const response = await getProductFilters(params, {
currency,
locale,
});
Expand All @@ -120,7 +124,7 @@ export function useProductListing({
};
// filterParams is stable per mount (object identity may differ but content is constant)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currency, locale, storeLoading]);
}, [currency, locale, storeLoading, searchQuery]);

// Load products when search query or store context changes
useEffect(() => {
Expand Down