From 47ef6bff7445d3729c80fd17fa47a5261d38daa6 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 29 Jan 2018 18:04:23 -0800 Subject: [PATCH] Fix not scrolling to top on PUSH fixes #3770 #3249 --- .../gatsby-react-router-scroll/src/ScrollBehaviorContext.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/gatsby-react-router-scroll/src/ScrollBehaviorContext.js b/packages/gatsby-react-router-scroll/src/ScrollBehaviorContext.js index 7b347b4a73b32..3c431db06558a 100644 --- a/packages/gatsby-react-router-scroll/src/ScrollBehaviorContext.js +++ b/packages/gatsby-react-router-scroll/src/ScrollBehaviorContext.js @@ -51,6 +51,9 @@ class ScrollContext extends React.Component { location: prevProps.location, } + // The "scroll-behavior" package expects the "action" to be on the location + // object so let's copy it over. + location.action = history.action this.scrollBehavior.updateScroll(prevRouterProps, { history, location }) }