We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe65c29 commit e7e5cb4Copy full SHA for e7e5cb4
packages/gatsby-react-router-scroll/src/scroll-handler.tsx
@@ -59,10 +59,13 @@ export class ScrollHandler extends React.Component<
59
scrollPosition = this._stateStorage.read(this.props.location, key)
60
}
61
62
- if (scrollPosition) {
63
- this.windowScroll(scrollPosition, undefined)
64
- } else if (hash) {
+ /** If a hash is present in the browser url as the component mounts (i.e. the user is navigating
+ * from an external website) then scroll to the hash instead of any previously stored scroll
+ * position. */
65
+ if (hash) {
66
this.scrollToHash(decodeURI(hash), undefined)
67
+ } else if (scrollPosition) {
68
+ this.windowScroll(scrollPosition, undefined)
69
70
71
0 commit comments