Gatsby's Link overrides scrolling behavior with anchors #7450
Labels
stale?
Issue that may be closed soon due to the original author not responding any more.
type: question or discussion
Issue discussing or asking a question about Gatsby
Description
When clicking on an anchor
<Link />
, Gatsby will take it upon itself to scroll to the corresponding element if it exists, or to the top of the page if it doesn't. Seegatsby/packages/gatsby-link/src/index.js
Lines 141 to 152 in 483749d
This is inconsistent with react-router's
<Link />
component which simply pushes a new history entry and leaves the scrolling up to the user.This behavior prohibits me from using Gatsby's
<Link />
for anchor links, as I want to override the scrolling part with a smooth scrolling behavior. Instead, I created my own<CustomLink />
component that uses Gatsby'spush
API.Steps to reproduce
Expected result
Clicking the Link doesn't affect the page's scroll.
Actual result
Clicking the Link affects the page's scroll.
Environment
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: