Skip to content

Commit 2a0dc67

Browse files
ivaskevychtannerlinsley
authored andcommitted
fix(usepagination resetpage on globalfilter change): pageIndex reset (TanStack#1813)
autoReset pageIndex on globalFilter change "fix TanStack#1812"
1 parent 8e310bd commit 2a0dc67

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

.size-snapshot.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919
}
2020
},
2121
"dist\\index.js": {
22-
"bundled": 104977,
23-
"minified": 48560,
24-
"gzipped": 13057
22+
"bundled": 113237,
23+
"minified": 52528,
24+
"gzipped": 13837
2525
},
2626
"dist\\index.es.js": {
27-
"bundled": 104090,
28-
"minified": 47770,
29-
"gzipped": 12900,
27+
"bundled": 112300,
28+
"minified": 51692,
29+
"gzipped": 13671,
3030
"treeshaked": {
3131
"rollup": {
3232
"code": 80,
3333
"import_statements": 21
3434
},
3535
"webpack": {
36-
"code": 8227
36+
"code": 8461
3737
}
3838
}
3939
}

docs/api/usePagination.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The following options are supported via the main options object passed to `useTa
3030
- When `true`, the `pageIndex` state will automatically reset if `manualPagination` is `false` and any of the following conditions are met:
3131
- `data` is changed
3232
- `manualSortBy` is `false` and `state.sortBy` is changed
33+
- `manualGlobalFilter` is `false` and `state.globalFilter` is changed
3334
- `manualFilters` is `false` and `state.filters` is changed
3435
- `manualGroupBy` is `false` and `state.groupBy` is changed
3536
- To disable, set to `false`

src/plugin-hooks/usePagination.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,19 @@ function useInstance(instance) {
7676
pageCount: userPageCount,
7777
paginateExpandedRows = true,
7878
expandSubRows = true,
79-
state: { pageSize, pageIndex, expanded, filters, groupBy, sortBy },
79+
state: { pageSize, pageIndex, expanded, globalFilter, filters, groupBy, sortBy },
8080
dispatch,
8181
data,
8282
manualPagination,
83+
manualGlobalFilter,
8384
manualFilters,
8485
manualGroupBy,
8586
manualSortBy,
8687
} = instance
8788

8889
ensurePluginOrder(
8990
plugins,
90-
['useFilters', 'useGroupBy', 'useSortBy', 'useExpanded'],
91+
['useGlobalFilter', 'useFilters', 'useGroupBy', 'useSortBy', 'useExpanded'],
9192
'usePagination',
9293
[]
9394
)
@@ -101,6 +102,7 @@ function useInstance(instance) {
101102
}, [
102103
dispatch,
103104
manualPagination ? null : data,
105+
manualPagination || manualGlobalFilter ? null : globalFilter,
104106
manualPagination || manualFilters ? null : filters,
105107
manualPagination || manualGroupBy ? null : groupBy,
106108
manualPagination || manualSortBy ? null : sortBy,

0 commit comments

Comments
 (0)