-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request]: <Pagination> to handle very large numbers of items #9754
Comments
Hi @s100, this has come up a few times
The easiest way to prevent this is to cap the amount of data sent to the table via your backend/API. Alternatively you could prevent the
In the future The page select dropdown can alternatively be removed altogether preventing the issue. |
I'm going to close this for now as I think my previous comment covers the use case of this pretty well. Let me know if not, we can always continue the discussion and reopen if necessary. Thanks for adding your experience as a data point on the topic - 40,000,000 items is a ton! 😵 |
Just to clarify about our use case: our customer does, in fact, have a database table with 40,000,000+ rows in it. At one row of data per second, it only takes a year and a bit to reach this figure. We're not at liberty to tell our customer to simply have less data, and it's not ideal to just lie to the Also, please note that we are not, of course, actually sending all 40,000,000+ rows of data to the browser for rendering. The way our application works is, it makes a query for one specific page of the data, and the response includes just the 25 or so rows which make up that one page of data, which we then put in a As a workaround, currently we are lying to I look forward to these possible solutions... |
Well, if anybody has the same problem as us and comes reading this bug, here's what we started doing: const CappedPagination = ({
itemRangeText,
itemText,
maxPages, // set this to e.g. 1000
page,
pageRangeText,
pageSize,
pagesUnknown,
totalItems,
...rest
}) => {
const fakeTotalItems = Math.min(totalItems, maxPages * pageSize)
const totalPages = Math.ceil(totalItems / pageSize)
const itemCap = pagesUnknown ? Infinity : totalItems
const min = Math.min(pageSize * (page - 1) + 1, itemCap)
const max = Math.min(pageSize * page, itemCap)
return (
<Pagination
totalItems={fakeTotalItems}
itemRangeText={(fakeMin, fakeMax, fakeTotalItems) => itemRangeText(min, max, totalItems)}
pageRangeText={(current, fakeTotalPages) => pageRangeText(current, totalPages)}
itemText={(fakeMin, fakeMax) => itemText(min, max)}
page={page}
pageSize={pageSize}
pagesUnknown={pagesUnknown}
{...rest}
/>
)
} This component shows all the correct output and controls, but caps the page dropdown to just 1000 options. |
…-system#9881) ### Related Ticket(s) Closes: carbon-design-system#9754 ### Description When disabled bx-dropdown is not interactive ### Changelog **Changed** - Fixed bug in bx-dropdown
Summary
We would like some sort of mechanism to make it so that when there are, say, 40,000,000 items to page through, at 25 items per page
<Pagination>
does not attempt to generate a dropdown with 1,600,000 options in it.Justification
We recently had a customer hit exactly this issue. They had 40,000,000 items and the
<Pagination>
component was causing their browser to apparently stall or crash while attempting to generate a dropdown list of all the pages. Simply omitting the<Pagination>
and showing an apologetic message is one option, but it would be nice to do a little better than that.Desired UX and success metrics
I don't have a full picture of how I would like this to look, beyond "it shouldn't crash the browser, no matter how many items there are"... capping the dropdown size at 1000 entries would be an acceptable start. This is what we are currently doing, manually.
A better approach would be to have some kind of exponential navigation where we are not provided with access to every page, but a representative sample which is sufficient for us to navigate. Say, pages 1-10, 20, 30, 40, ..., 100, 200, 300, ... 1,599,900, 1,599,910, ..., 1,599,980, 1,599,990-1,600,000. If the current page number is somewhere in the middle, provide exponential options around that point, too.
Required functionality
The existing functionality of the
<Pagination>
component is acceptable. This I think is mainly an alteration to how it generates its page selections.Specific timeline issues / requests
No specific timeline... we are working around the problem right now.
Available extra resources
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: