Skip to content

Commit

Permalink
Merge pull request #134 from irontec/CDL-63-filter-correctly-when-we-…
Browse files Browse the repository at this point in the history
…are-in-a-list-with-pagination

Fixed a bug when performing a search when we are in a list with pagination
  • Loading branch information
R0MANDEV authored Sep 11, 2024
2 parents 37f358c + 0a4f648 commit 921d72a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irontec/ivoz-ui",
"version": "1.5.0",
"version": "1.5.1",
"description": "UI library used in ivozprovider",
"license": "GPL-3.0",
"main": "index.js",
Expand Down
14 changes: 10 additions & 4 deletions library/src/components/List/Content/FastSearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const FastSearchField = (
): JSX.Element => {
const { className, path, entityService, ignoreColumn } = props;

const queryStringCriteria = useStoreState((state) => [
...state.route.queryStringCriteria,
]);
const storeQueryStringCriteria = useStoreState(
(state) => state.route.queryStringCriteria
);
const setQueryStringCriteria = useStoreActions((actions) => {
return actions.route.setQueryStringCriteria;
});
Expand Down Expand Up @@ -69,6 +69,8 @@ const FastSearchField = (

let match = false;
let matchIdx: string | undefined;

const queryStringCriteria = [...storeQueryStringCriteria];
for (const idx in queryStringCriteria) {
if (queryStringCriteria[idx].name !== firstColumnCriteria.name) {
continue;
Expand All @@ -90,7 +92,11 @@ const FastSearchField = (
queryStringCriteria.splice(parseInt(matchIdx, 10), 1);
}

setQueryStringCriteria(queryStringCriteria);
const queryStringCriteriaWithoutPagination = queryStringCriteria.filter(
(criteria) => criteria.name !== '_page'
);

setQueryStringCriteria(queryStringCriteriaWithoutPagination);
};

const changeHandler: React.ChangeEventHandler<HTMLInputElement> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const useFirstColumnCriteria = (
undefined | CriteriaFilterValue
>(undefined);

const queryStringCriteria = useStoreState((state) => [
...state.route.queryStringCriteria,
]);
const queryStringCriteria = useStoreState(
(state) => state.route.queryStringCriteria
);

const storeState = useStoreState(
(state) => state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ export default function ContentFilterSelector(
variant='contained'
disabled={criteria.length < 1}
onClick={() => {
commitCriteria(criteria);
const queryStringCriteriaWithoutPagination = criteria.filter(
(criteria) => criteria.name !== '_page'
);
commitCriteria(queryStringCriteriaWithoutPagination);
}}
>
{_('Apply')}
Expand Down

0 comments on commit 921d72a

Please sign in to comment.