diff --git a/packages/shared/src/utils/table/hooks/useUrlSearchParamsStatus.ts b/packages/shared/src/utils/table/hooks/useUrlSearchParamsStatus.ts index 91476db30f1..9eca9afbdcd 100644 --- a/packages/shared/src/utils/table/hooks/useUrlSearchParamsStatus.ts +++ b/packages/shared/src/utils/table/hooks/useUrlSearchParamsStatus.ts @@ -111,14 +111,24 @@ const pickUrlSearchParams = (params: URLSearchParams | string, pickKeys: string[ return newParams; }; -export const useUrlSearchParamsStatus = (omitKeys: string[] = []) => { +export const useUrlSearchParamsStatus = ( + omitKeys: string[] = [], +): { + state: Partial; + setState: (state: Partial, type: keyof TableState) => void; + params: URLSearchParams; + setParams: (params: URLSearchParams) => void; +} => { const [params, setParams] = useSearchParams(); const paramsRef = React.useRef(params.toString()); const [state, setState] = React.useState>( urlParams2Status(omitUrlSearchParams(params, omitKeys)), ); - const handleState = React.useCallback((_state: Partial) => { + const handleState = React.useCallback((_state: Partial, type: keyof TableState) => { + if (type === 'columnFilters') { + set(_state, 'pagination.pageIndex', 0); + } const newParams = status2UrlParams(_state, pickUrlSearchParams(paramsRef.current, omitKeys)); setState(_state); paramsRef.current = newParams.toString();