react-component / react-component/pagination

itemRender customizes NOT list-item but <a>, so it doesn't properly support <Link>

Open
#374 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
674
Forks
333
Avg merge
12m
Merged PRs (30d)
1

Description

I am trying to wrap each pager item into <Link> (from next/link or react-router-dom).

My code is something like following:

<Pagination
    defaultPageSize={perPage}
    itemRender={(current, type, element) => {
        return <Link href={'/base_href/' + current}>{element}</Link>
    }}
    current={page}
    total={total}
    style={{ float: 'right', margin: 0 }}
/>

Expected result:

  1. The whole pager is clickable, and makes cursor pointer.
  2. The whole pager shows hint "/base_href/..." on mouse over.
  3. Clicking each point of pager element causes navigation to the link.

Actual result:

  1. The whole pager is clickable, and makes cursor pointer.
  2. Pager shows hint "/base_href/..." on mouse over only on its center (digit), but not border.
  3. To navigate, user should click pager's center (digit), but not border.

So, it renders as:

<li>
    <Link>
        <a></a>
    </Link>
</li>

but, in order to meet expectations, it should render as:

<Link>
    <li>
        <a></a>
    </li>
</Link>

Or, at least, it should forward <li> click event to <a> element (which will fix No. 3, but not No. 2)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Pagination itemRender implementation and inspect how the returned element is placed relative to the generated

  • and . Reproduce the example with next/link or react-router-dom and verify that the whole pager item carries the link target, hover hint, and click behavior.

  • Written by the indexing model from the issue text.

    Assessment

    Tech stack
    react, typescript
    Domain
    frontend
    Issue type
    Bug
    Difficulty
    3/5
    Estimated time
    1-2 days
    Activity status
    Stale
    Clarity
    Mostly clear
    Newbie friendliness
    38/100

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.