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

Add property to allow custom breakLabel behaviour #263

Closed
Mairu opened this issue Feb 19, 2019 · 5 comments
Closed

Add property to allow custom breakLabel behaviour #263

Mairu opened this issue Feb 19, 2019 · 5 comments

Comments

@Mairu
Copy link
Contributor

Mairu commented Feb 19, 2019

In version 5 of this package I used a link with custom change page handling logic provided as breakLabel.

Starting with version 6 this is not possible anymore.
So it would be nice if it would be possible to provide custom breakLabel click handling.

Mairu added a commit to Mairu/react-paginate that referenced this issue Feb 19, 2019
Mairu added a commit to Mairu/react-paginate that referenced this issue Feb 19, 2019
Mairu added a commit to Mairu/react-paginate that referenced this issue Feb 19, 2019
Mairu added a commit to Mairu/react-paginate that referenced this issue Feb 19, 2019
@kstratis
Copy link

kstratis commented May 8, 2019

Bumped into the same issue today.

I just used the e.stopPropagation() and slipped in my custom behaviour...

@AdeleD
Copy link
Owner

AdeleD commented Sep 6, 2020

I'm not sure to understand what you're trying to do but you could probably use the onPageChange prop. No?

@Mairu
Copy link
Contributor Author

Mairu commented Sep 7, 2020

The onPageChange prop is called for every page change. The custom logic I was referring to is a popup where you can enter the page number you want to jump to.

As kstratis has stated, with the usage of e.stopPropagation it is possible to prevent the onPageChange prop to be called when clicking the node which you can set as breakLabel. Although you can only use text node elements (at least to the browser warnings, because the breakLabel is nested in an a element).

Because there is this workaround I could understand to not implement that "feature".

@AdeleD
Copy link
Owner

AdeleD commented Sep 7, 2020

Ok, I see what you mean.

@MonsieurV
Copy link
Collaborator

Hi,

You can now use the callback onClick, which will expose several data about what has been clicked on the the component.

For eg when you click a break element:

image

In your case you can use the isBreak property to detect a click on a break, and then return false to prevent any page change to take place. This will give something like that:

<ReactComponent
    onClick={(clickEvent) => {
       if (clickEvent.isBreak) return false;
    }
/>

You can also control the page to jump to by returning a number. Returning nothing or undefined let the default behavior happen.


You can test it with:

npm install --save github:AdeleD/react-paginate#v8.1.0 

@AdeleD could we release v8.0.3 and v8.1.0 to NPM?
They are tagged.
Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants