gatsby-plugin-transition-link icon indicating copy to clipboard operation
gatsby-plugin-transition-link copied to clipboard

TransitionLink strips hash from URL

Open NerdCowboy opened this issue 5 years ago • 6 comments

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.

NerdCowboy avatar May 21 '20 18:05 NerdCowboy

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

imshuffling avatar Nov 13 '20 12:11 imshuffling

@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.

NerdCowboy avatar Nov 13 '20 18:11 NerdCowboy

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

imshuffling avatar Nov 16 '20 09:11 imshuffling

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 avatar Dec 09 '20 17:12 patsa

@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?

patsa avatar Dec 14 '20 15:12 patsa

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

imshuffling avatar Jan 04 '21 13:01 imshuffling