feat: number input page for performance#22128
feat: number input page for performance#22128devadula-nandan wants to merge 7 commits intocarbon-design-system:mainfrom
Conversation
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for v11-carbon-web-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for v11-carbon-web-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22128 +/- ##
==========================================
+ Coverage 95.09% 97.88% +2.79%
==========================================
Files 541 196 -345
Lines 45239 30668 -14571
Branches 6511 1579 -4932
==========================================
- Hits 43018 30018 -13000
+ Misses 2092 641 -1451
+ Partials 129 9 -120
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Thanks for taking a look at this! A few loosely held opinions come to mind:
If there's a clear UX benefit to direct entry via a text/number input, I think we should consider making that the default and doing away with select entirely. We could do that with a feature flag. Maybe do away with preview__Pagination
On the other hand, if we have reason to believe it should switch, would there be a benefit to trying a more composable approach like preview__Pagination?
If we use a type="number" input, I think the stepper buttons should be hidden.
To me, visually, the text/number input does not immediately appear to be editable. This might need some design exploration?
I think it makes sense to update onChange instead of onKeyDown. Feels like better UX, no page thrashing if you type numbers one at a time. With onKeyDown you'd have like 324 -> Page 3, Page 32, Page 324
|
After reviewing preview pagination and patterns from the references today, here are the key observations:
Design challengeThe number input needs a clear visual affordance to indicate editability.
Possible indicators:
The toolbar-style triangular indicator is a potential option, though its suitability here is uncertain. New Acceptance criteria to move forward
|

Closes #5546
Closes #6884
Closes #16895
Closes/Contributes to
#6836
#5129
#6146
#21661
#4365
#21053
Renders a number input instead of a select when there are more than 30 pages to navigate, which significantly improves performance and holds up under extreme stress tests.
More Notes
Having two different UIs may raise concerns about design inconsistency. For example, imagine a dataset with 300 items, resulting in 30 pages (with a page size of 10). If a new item is added, the component flips from a select to a number input—and vice versa if the 301st item is removed.
Now consider two pages, each rendering data tables. The first has 12 items in total, while the second has 12,345,678 items. Page 1 will render a select, whereas page 2 will render a number input.
If we consider this an inconsistency, the performance benefits outweigh the design concerns. Our goal is to build usable components—not ones that block user flow or hang the browser.
Based on these findings (observed since 2019), the select component is not the right choice for large datasets. If we want consistent rendering across all screens, we should choose a number input over a select.
Safer Approach
A safer approach is to provide a configurable prop for the threshold, allowing users to choose between a select and a number input. This behavior would not be enabled by default but offered as an optional enhancement.
threshold == 0→ always render a number inputthreshold == Infinity→ always render a selectThis change may break some tests for adopters that rely on page count behavior, unless we provide this prop and set the default to
Infinity. Adopters would then need to manually opt in for the performance improvement.Conclusion
We should prioritize practicality and usability. Components must be battle-tested for extreme use cases, remain performant, and avoid lagging or freezing the browser due to excessive resource consumption, which negatively impacts UX.
If consistency in design is required, the correct approach is to standardize on number input from the start. The select component is inherently non-scalable and should be treated as such.
TODO: contribute to WC once react design/behavior/a11y is finalized
Changelog
New
Changed
Removed
Testing / Reviewing
totalItemsadd 300 and notice it renders select. make it 301 and notice it renders number input.totalItemsand notice it doesnt effect the performance & observe there is no load on browser resourcesPR Checklist
As the author of this PR, before marking ready for review, confirm you:
More details can be found in the pull request guide