Open vineetdpnd opened 2 months ago
Hey @vineetdpnd! 👋 I'm here to help you with any bugs, questions, or contributions you have for Superset. Let's tackle this together!
To address the issue of pagination not resetting on charts after updating an applied filter, you can use the useEffect
hook to clear the cache and reset the page index whenever the filters change. This is already implemented in the Superset codebase as follows:
// Clear cache and reset page index if filters change
useEffect(() => {
setResponseError('');
setResultsPages(new Map());
setPageIndex(0);
}, [filters]);
This useEffect
hook ensures that whenever the filters
state changes, the responseError
is cleared, the resultsPages
cache is reset, and the pageIndex
is set to 0. This effectively resets the pagination to the first page, avoiding loading issues [1].
Additionally, in the buildQuery
function, there is logic to reset the row_offset
to 0 if the filters have changed, ensuring that the pagination starts from the first page:
if (
formData.server_pagination &&
options?.extras?.cachedChanges?.[formData.slice_id] &&
JSON.stringify(options?.extras?.cachedChanges?.[formData.slice_id]) !==
JSON.stringify(queryObject.filters)
) {
queryObject = { ...queryObject, row_offset: 0 };
updateExternalFormData(
options?.hooks?.setDataMask,
0,
queryObject.row_limit ?? 0,
);
}
This ensures that the pagination is reset on the server side as well, providing a consistent experience when filters are updated [2].
To continue talking to Dosu, mention @dosu.
We have checked it, the limit & offset value is not reset on the queries post change of the applied filters, so it does seem to be bug
Bug description
When server pagination is enabled on a chart and the page is navigated to a higher page number (e.g., 10th page), applying a new filter with a shorter time range (which would result in fewer pages) causes the chart to not load data. It seems that the pagination is not being reset after the filter is updated, causing the chart to request data for a page that no longer exists.
How to reproduce the bug
Screenshots/recordings
No response
Superset version
4.0.2
Python version
3.11
Node version
16
Browser
Chrome
Additional context
No response
Checklist