Skip to content

Commit

Permalink
fix: reset paging when clearing filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Jan 29, 2024
1 parent 5c06c37 commit fdb0b10
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/lib/sectionList/filters/useSectionListFilters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useCallback, useMemo } from 'react'
import { useQueryParams } from 'use-query-params'
import {
usePaginationQueryParams,
useUpdatePaginationParams,
} from '../usePaginationParams'
import { usePaginationQueryParams } from '../usePaginationParams'
import {
ParsedFilterParams,
filterQueryParamType,
Expand Down Expand Up @@ -34,9 +31,10 @@ export const useSectionListFilters = () => {
const resetParams = Object.fromEntries(
validFilterKeys.map((key) => [key, undefined])
)
return setFilterParams(resetParams)
setFilterParams(resetParams)
} else {
setFilterParams(filter, updateType)
}
setFilterParams(filter, updateType)
// set page to 1 when filter changes
// do this here instead of useEffect to prevent unnecessary refetches
setPagingParams((pagingParams) => ({ ...pagingParams, page: 1 }))
Expand Down

0 comments on commit fdb0b10

Please sign in to comment.