Skip to content

Pagination is broken if there is only one page #1048

Open
@sergiivorobei

Description

@sergiivorobei
  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Steps to reproduce

  1. Render pagination component with this props:
<Pagination 
  currentPage={1} 
  totalPages={1} 
  showIcons
  nextLabel=""
  previousLabel=""
/>

Current behavior

There is no 1 between the arrows, just two buttons (previous and next)
Screenshot 2023-10-06 at 11 33 51

Expected behavior

1 is shown between the arrows, similarly to the case when we have 2 and more pages.
image

Context

I would like to show the Pagination component with only one page when user has a small amount of data.

The problem is in range function, where this check is contained

if (start >= end) {
    return [];
}

I would assume it should be

if (start > end) {
    return [];
}

but not sure whether this breaks the expected behaviour from your side. If you are fine I can create the PR.

Thanks,
Sergii

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions