Bug description

  1. On Mixed Chart click "View as Table"
  2. Paginate to the last page
  3. Input some text into search bar, not present in the table
  4. Get an error getPaginationModel(): currentPage shouldn't be greater than totalPages Seems like bug not relevant to chart, more likely React-specific

Screenshots/recordings

1

Superset version

4.1.1

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

Hello, @Splinterfeel! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together!

The error you're encountering, "getPaginationModel(): currentPage shouldn't be greater than totalPages," typically occurs when the pagination state is not updated correctly after a search query that returns fewer results than the current page. In Superset, when the dataset changes, such as when a search query is performed, the pagination state should be recalculated to ensure the current page is within valid bounds.

The Superset codebase handles this by checking if the current page index is greater than the total number of pages minus one. If this condition is true and there are pages available, it resets the page index to zero. This is done using the following logic:

useEffect(() => {
  if (!loading && pageIndex > pageCount - 1 && pageCount > 0) {
    gotoPage(0);
  }
}, [gotoPage, loading, pageCount, pageIndex]);

This ensures that if a search query returns fewer results than the current page, the pagination state is updated to show the first page of the new result set [1].

To resolve the issue, you may need to ensure that this logic is correctly implemented in the components handling pagination and search functionality, such as index.tsx, Input.js, and singleQueryResultPane.tsx.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

Comment From: rusackas

I was able to reproduce this once, and only once, in 4.1.2. In general, it seems to work fine, in that when you type something into the search box, it moves you to page 1, and then applies the filter, which works fine. If anyone is still facing this, the bot's suggestion sounds correct, so I'll at least call this a good first issue

Comment From: rusackas

Spinning up a test environment on the linked PR. Lemme know if it fixes things or not :)