TylerBarnes / gatsby-plugin-transition-link

A link component for page transitions in gatsby
537 stars 70 forks source link

TransitionLink strips hash from URL #209

Open NerdCowboy opened 4 years ago

NerdCowboy commented 4 years ago

I'm using hash links to navigate between tabs on a page. If I navigate to a different page, I have a back link which shows the correct url and hash, i.e /#tab1, but when I click it, TransitionLink strips the hash from the url and I end up on the wrong tab. (btw if there's a better way to do this in Gatsby without re-rendering the entire page, I'm all ears)

It appears this is the offending code https://github.com/TylerBarnes/gatsby-plugin-transition-link/blob/d09fc98647a8721e3d64321cf41d96191b07261b/src/utils/triggerTransition.js#L31

Not sure if it's necessary to strip the hash off for other reasons, but happy to make a PR if we can just delete that line.

imshuffling commented 3 years ago

@NerdCowboy I'm having the same issue here, did you find a workaround?

NerdCowboy commented 3 years ago

@imshuffling I can't quite recall—my project got shut down. I think I either turned off the transition or I might've stored the tab state in a global provider and reactivated the tab on page load.

imshuffling commented 3 years ago

@NerdCowboy thanks, for my use case I used a standard a href link on mobile which worked ok.

patsa commented 3 years ago

I have the same problem and am currently looking for a solution.

See #249 for a detailed description.

I do understand, that it would be possible to store the hash value in a global provider, but that seems unintuitive to me, as the wrong behavior is clearly related to this plugin.

patsa commented 3 years ago

@imshuffling @NerdCowboy Could someone explain to me, how I can store the hash before triggering the transition and how to retrieve it afterwards while triggering the scroll effect manually?

imshuffling commented 3 years ago

@patsa I just used a standard a href if on mobile, which worked for my use-case. Didn't actually get it to work.