-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Link should perform a replace when navigating to the current page #22124
Comments
Ok, so seems like reach/router fixed this only when using reach/router Link components, but we do overwrite this and call I'm not exactly sure when |
Exactly, gatsby uses the imperative I'm not aware whether removing the |
It's not that simple, because our navigation code also handle resource loading (primary reason why we don't use reach/router link components really) before doing actual navigation. Otherwise we would have flashes of content if use reach navigation and only after load resources |
We also can't use something like Suspend because minimal react version supported by gatsby@2 doesn't have Suspend support :S (not to mention that data loading with Suspense is not yet stable AFAIK and throwing method to suspend might not be the final API in react (?) ) |
Maybe solution here would be to move the checks in I wonder what @blainekasten thinks about this ;) |
Gotcha, yeah I didn't dig into the "whys" at all. Understood. Perhaps mimicking the same logic that exists in Would you accept a PR to add a behavior similar to this? I know it's not optimal, but it's a solution |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
Fixes gatsbyjs#22124 If the developer didn't explicitly set the "replace" prop and we're on the page that we're about to navigate to, force "replace" to true when navigating. This fixes a bug where clicking a link that does not result in navigating to another page incorrectly adds an history entry. Uses the same technique as @reach/router
… it (#23414) Fixes #22124 If the developer didn't explicitly set the "replace" prop and we're on the page that we're about to navigate to, force "replace" to true when navigating. This fixes a bug where clicking a link that does not result in navigating to another page incorrectly adds an history entry. Uses the same technique as @reach/router
Description
When rendering a
<Link>
fromgatsby-link
which points to the current location, then each click pushes a new entry into the history stack. Thus, If I click a link (pointing to the page that I'm on) multiple times, then I require the same amount of browser "back button" presses, in order to leave my current page.Natively, browsers implement a history "replace" and not a "push" when the anchor tag points to the current URL. I feel that gatsby's
Link
should to the same.There was also a related issue in reach router
Steps to reproduce
Start by creating a new site
Then:
localhost:8000
Gatsby Default Starter
multiple timesExpected result
You would expect to go back to your tab's initial page
Actual result
Nothing happens until you press back a lot of times (as many as your
Gatsby Default Starter
clicks)Environment
System:
OS: macOS 10.15.2
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.16.0 - /usr/local/bin/node
Yarn: 1.19.0 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 80.0.3987.132
Firefox: 72.0.2
Safari: 13.0.4
npmPackages:
gatsby: ^2.18.1 => 2.19.19
gatsby-image: ^2.2.33 => 2.2.41
gatsby-plugin-brotli: ^1.3.1 => 1.3.1
gatsby-plugin-manifest: ^2.2.29 => 2.2.41
gatsby-plugin-netlify: ^2.1.33 => 2.1.33
gatsby-plugin-offline: ^3.0.22 => 3.0.35
gatsby-plugin-prefetch-google-fonts: ^1.4.3 => 1.4.3
gatsby-plugin-react-helmet: ^3.1.15 => 3.1.22
gatsby-plugin-sass: ^2.1.23 => 2.1.29
gatsby-plugin-sharp: ^2.3.2 => 2.4.5
gatsby-plugin-sitemap: ^2.2.27 => 2.2.27
gatsby-plugin-typescript: ^2.1.27 => 2.1.27
gatsby-source-filesystem: ^2.1.38 => 2.1.48
gatsby-transformer-sharp: ^2.3.5 => 2.3.14
npmGlobalPackages:
gatsby-cli: 2.10.4
The text was updated successfully, but these errors were encountered: