mauricevancooten / react-anchor-link-smooth-scroll

React component for anchor links using the smooth scroll polyfill.
243 stars 31 forks source link

Hash doesn't change in the address bar #5

Closed gazpachu closed 6 years ago

gazpachu commented 6 years ago

It might not be an issue, but I've noticed that, after changing my a tags to AnchorLink, the hash in the address bar doesn't change any more.

It could be fixed by adding an onClick event to the AnchorLinks and setting manually the hash, but I was wondering if we could add this feature to the module.

Thanks!

gazpachu commented 6 years ago

Correction: the onClick event in the AnchorLink doesn't work either

mauricevancooten commented 6 years ago

I'm wondering for which use case scenario you'll need the hash to be in the address bar?

gazpachu commented 6 years ago

I.e. a top nav with links that when clicked scroll to the given section. After the animation ends, the address bar will get the hash of the section, in case the user decides to share a link to that page and section. Like in the wikipedia articles.

By the way, I fixed the onClick issue by adding an 'if' to the last expression inside the SmooScroll method:

If (this.props.onClick) this.props.onClick(e);

mauricevancooten commented 6 years ago

If you want to create a pull request with the fix I'll be happy to include it. Thanks for your enquiry.