Skip to content
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

ScalePagination does not disable previous navgiation when 0 items in pagination and displays "1 - 0/0" #2311

Open
FlixFix opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@FlixFix
Copy link

FlixFix commented Apr 19, 2024

Scale Version
v3.0.0-beta.117 (also present in newest version)

Framework and version
We are using the ReactComponents, however the issue is also present in the component template.

Current Behavior
When creating a pagination element, with 0 entries and, therefore, a start element with index 0, the default display of the pagination will display items "1 - 0 / 0". When trying to trick this by providing "-1" as the start index for the pagination, the previous page navigation button will be enabled.

Expected Behavior
When providing a total element count of "0" to the pagination, the pagination should display "0 - 0 / 0" and all navigation buttons should be disabled.

Code Reproduction
<ScalePagination size="small" pageSize={5} onPagination={() => void} startElement={0} totalElements={0}/>

Desktop (please complete the following information):

  • all

Smartphone (please complete the following information):

  • all

Additional context
The problem lies within https://github.com/telekom/scale/blob/main/packages/components/src/components/pagination/pagination.tsx:


const start = this.startElement + 1;
...
const isAtStart = start === 1;

Modifying this to:

const start = total === 0 ? 0 : startElement + 1;
const isAtStart = start === 1 || total === 0;

will resolve the issue.

@FlixFix FlixFix added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant