Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Save search query

dominik-zeglen35d09661bf90
diff --git a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
index 7d7b7f1739..f34a57de4b 100644
--- a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
@@ -31,7 +31,8 @@ export enum ProductFilterKeys {
price,
priceEqual,
priceRange,
- stock
+ stock,
+ query
}
const filterMenu: IFilter = [
{
diff --git a/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
index 5b589e3baa..78e72426e8 100644
--- a/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList/ProductList.tsx
@@ -89,18 +89,12 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
};
const changeFilterField = (filter: ProductListUrlFilters) => {
- const hasOnlyQueryChanged =
- filter.query !== undefined &&
- Object.keys(filter)
- .filter((key: keyof ProductListUrlFilters) => key !== "query")
- .every(key => !filter[key]);
-
reset();
navigate(
productListUrl({
...getActiveFilters(params),
...filter,
- activeTab: hasOnlyQueryChanged ? params.activeTab : undefined
+ activeTab: undefined
})
);
};
@@ -118,8 +112,7 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
navigate(
productListUrl({
activeTab: tab.toString(),
- ...getFilterTabs()[tab - 1].data,
- query: params.query
+ ...getFilterTabs()[tab - 1].data
})
);
@@ -255,11 +248,7 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
selected={listElements.length}
toggle={toggle}
toggleAll={toggleAll}
- onSearchChange={query =>
- changeFilterField({
- query
- })
- }
+ onSearchChange={query => changeFilterField({ query })}
onFilterAdd={filter =>
changeFilterField(createFilter(filter))
}
diff --git a/saleor/static/dashboard-next/products/views/ProductList/filters.ts b/saleor/static/dashboard-next/products/views/ProductList/filters.ts
index ee7bdf219a..38d96648d1 100644
--- a/saleor/static/dashboard-next/products/views/ProductList/filters.ts
+++ b/saleor/static/dashboard-next/products/views/ProductList/filters.ts
@@ -46,9 +46,7 @@ export function getActiveFilters(
}
export function areFiltersApplied(params: ProductListUrlQueryParams): boolean {
- return Object.keys(getActiveFilters(params))
- .filter((key: keyof ProductListUrlFilters) => key !== "query")
- .some(key => !!params[key]);
+ return Object.keys(getActiveFilters(params)).some(key => !!params[key]);
}
export function createFilter(
@@ -212,10 +210,7 @@ export function saveFilterTab(name: string, data: ProductListUrlFilters) {
JSON.stringify([
...userFilters,
{
- data: {
- ...data,
- query: undefined
- },
+ data,
name
}
])