villainoustourist / Blazor.Pagination

A reusable pagination component for Blazor.
MIT License
38 stars 18 forks source link

Visible page buttons count is off by one at last page #5

Open hhyyrylainen opened 3 years ago

hhyyrylainen commented 3 years ago

Describe the bug I noticed when limiting the visible pages to 3, that when I go to the last page, 4 pages are visible.

To Reproduce Steps to reproduce the behavior:

  1. Make a paginator with a bunch of pages and limit to 3 visible pages
  2. Go to the last page
  3. See that 4 page buttons are visible

Looks like the same issue happens with the visible buttons being set to 5 as well (I just noticed when messing with configuring the visible buttons based on browser window size).

Expected behavior I expected there to be 3 visible page buttons when at the last page, like there is at the first page.

Screenshots Everything fine when at the start: Kuvakaappaus - 2021-03-22 19-52-48

Going to the last page shows this: Kuvakaappaus - 2021-03-22 19-52-43

Going to page 14 looks correct (page 15 acts like the last page): Kuvakaappaus - 2021-03-22 19-52-58

Desktop (please complete the following information):

villainoustourist commented 3 years ago

@hhyyrylainen Thank you for the report. While investigating, I've updated the example code at commit 3e4b3e5. Can you provide any more detail? Number of items in this list, etc?

hhyyrylainen commented 3 years ago

Here's the JSON response for fetching the last page (where this problem is shown):

{
    "lastRowOnPage": 48,
    "firstRowOnPage": 46,
    "rowCount": 48,
    "pageSize": 3,
    "pageCount": 16,
    "currentPage": 16,
    "results": [
        {
            "data": "redacted from here"
        },
        {
            "data": "redacted from here"
        },
        {
            "data": "redacted from here"
        }
    ]
}

I limited the items per page to 3 as I don't otherwise have enough data to get a bunch of pages.

Here's my source code on how I use show this data: https://github.com/Revolutionary-Games/ThriveDevCenter/blob/13f383cf82957abe60f60d3309fccda0e864aa64/Client/Pages/UserList.razor#L27 and this is where the paginator component is used: https://github.com/Revolutionary-Games/ThriveDevCenter/blob/8613beff52ac690d0e6841966f2c43a6b400c73c/Client/Shared/PaginatedTable.razor#L47 I don't think I do anything particularly crazy. I adapt the shown page count based on the browser size.

I tried also with page sizes of (item count per page) 5 and 10, and those also show the same problem.