fix(ui): fix NaN input in Pagination#1794
Conversation
Signed-off-by: I531348 <guoda.puidokaite@sap.com>
There was a problem hiding this comment.
Pull request overview
Fixes an input-edge-case in the Pagination component (input variant) so that non-numeric values no longer result in NaN being shown, aligning behavior with the expectation to fall back to the last available page.
Changes:
- Clamp non-numeric (
NaN) input values tocontrolTotalPage(last page) in the input handler. - Add a regression test covering symbol/non-numeric input behavior.
- Add a changeset to release the fix as a patch for
@cloudoperators/juno-ui-components.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/ui-components/src/components/Pagination/Pagination.component.tsx | Treats NaN input as invalid and falls back to the last page (controlTotalPage). |
| packages/ui-components/src/components/Pagination/Pagination.test.tsx | Adds a regression test for non-numeric input handling in the input variant. |
| .changeset/eleven-buses-bet.md | Declares a patch release note for the Pagination NaN input fix. |
|
Signed-off-by: I531348 <guoda.puidokaite@sap.com>
There was a problem hiding this comment.
hmm, this won't work if controlTotalPage is undefined. Imo a better way to deal with NaN values is to add it to the inputValue < 1 case instead, because there is always going to be a first page.
ArtieReus
left a comment
There was a problem hiding this comment.
what about adding following tests:
- What happens when totalPages is undefined and user enters non-numeric input
- Edge cases like empty string, whitespace, special characters beyond just "$"
The test only covers the case where totalPages={5} is defined.

Summary
When NaN input is entered, instead of printing
NaN, the last available page is defaulted to.Related Issues
Closes #1793
Checklist
PR Manifesto
Review the PR Manifesto for best practises.