mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Table: Update page index on data update (#81574)
* fix(table): page index reset on data update
This commit is contained in:
parent
6c42bd31c6
commit
1abe4a02b4
@ -237,6 +237,17 @@ export const Table = memo((props: Props) => {
|
|||||||
setPageSize(pageSize);
|
setPageSize(pageSize);
|
||||||
}, [pageSize, setPageSize]);
|
}, [pageSize, setPageSize]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Reset page index when data changes
|
||||||
|
// This is needed because react-table does not do this automatically
|
||||||
|
// autoResetPage is set to false because setting it to true causes the issue described in
|
||||||
|
// https://github.com/grafana/grafana/pull/67477
|
||||||
|
if (data.length / pageSize < state.pageIndex) {
|
||||||
|
gotoPage(0);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
useResetVariableListSizeCache(extendedState, listRef, data, hasUniqueId);
|
useResetVariableListSizeCache(extendedState, listRef, data, hasUniqueId);
|
||||||
useFixScrollbarContainer(variableSizeListScrollbarRef, tableDivRef);
|
useFixScrollbarContainer(variableSizeListScrollbarRef, tableDivRef);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user