Skip to content

Bug: first/prev links not rendered on second page #622

Closed
@bart-degreed

Description

@bart-degreed

Description

When using paging, the first and prev links are not rendered on the second page.

Example:
First page is at URL /api/books (A), which contains a link to next page: /api/books/?page[number]=1 (B). That page contains a link to its next page: /api/books/?page[number]=2 (C).

Observed behavior:
Page C contains top-level links for first and prev, but they are missing on page B.

Expected behavior:
I think the correct behavior would be for first and prev to exist also on page B, because it is the second page.

I traced this down to LinkBuilder.SetPageLinks(...), which conditionally sets them:

if (_pageService.CurrentPage > 1)
{
    links.First = GetPageLink(primaryResource, 1, _pageService.PageSize);
    links.Prev = GetPageLink(primaryResource, _pageService.CurrentPage - 1, _pageService.PageSize);
}

I think the condition should be changed to > 0, as index 0 appears to be the first page.

Environment

latest version of Develop branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions