Trim queries with whitespace (#2002)
* Disable rank sorting when query is empty * Trim query in handlers * Fix crash on empty query
This commit is contained in:
parent
f24f7b3089
commit
b9d94ccd83
2 changed files with 5 additions and 3 deletions
|
@ -14,6 +14,8 @@ export function useSortRedirects(
|
|||
) {
|
||||
const navigate = useNavigator();
|
||||
|
||||
const hasQuery = !!params.query?.trim();
|
||||
|
||||
useEffect(() => {
|
||||
const sortWithQuery = ProductListUrlSortField.rank;
|
||||
const sortWithoutQuery =
|
||||
|
@ -23,8 +25,8 @@ export function useSortRedirects(
|
|||
navigate(
|
||||
productListUrl({
|
||||
...params,
|
||||
asc: params.query ? false : params.asc,
|
||||
sort: params.query ? sortWithQuery : sortWithoutQuery
|
||||
asc: hasQuery ? false : params.asc,
|
||||
sort: hasQuery ? sortWithQuery : sortWithoutQuery
|
||||
})
|
||||
);
|
||||
}, [params.query]);
|
||||
|
|
|
@ -62,7 +62,7 @@ function createFilterHandlers<
|
|||
after: undefined,
|
||||
before: undefined,
|
||||
activeTab: undefined,
|
||||
query
|
||||
query: query?.trim()
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue