rafgraph / react-router-hash-link

Hash link scroll functionality for React Router
https://react-router-hash-link.rafgraph.dev
MIT License
732 stars 62 forks source link

How to prevent default redirection on "main"-tab when you control-click a link #80

Closed Parweiz closed 3 years ago

Parweiz commented 3 years ago

First of all, I'd thank all the contributions for this awesome package. It works smooth for me.

Now, for my issue. Is there a way to prevent the app to route to a specific section when you control-click links? What I mean by that is that, if I control click a link, then both the "main"-tab and the new tab redirects me to a specific section.

That's not supposed to happen, as the whole point with control-click links is that you open the content/link on a new tab meanwhile the "main"-tab stands still.

PS.: I used the provided URL for live demo app.

rafgraph commented 3 years ago

Hi, thanks for reporting the issue, I think it's a bug. The functionality should probably mimic React Router and ignore clicks with modifier keys: https://github.com/ReactTraining/react-router/blob/fc91700e08df8147bd2bb1be19a299cbb14dbcaa/packages/react-router-dom/modules/Link.js#L17-L19

Feel free to make a PR, or I can try to get to it.

rafgraph commented 3 years ago

@Parweiz this should be fixed in v2.4.2