diff --git a/gatsby-browser.js b/gatsby-browser.js index c66e4533d..a973fa435 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -55,4 +55,27 @@ const onClientEntry = () => { window.ReactDOM = require('react-dom'); }; -export { wrapPageElement, onInitialClientRender, onClientEntry }; +const shouldUpdateScroll = ({ routerProps: { location } }) => { + const PAGE_OFFSET_HEIGHT = 575; + const IS_IO = location.pathname.includes('instant-observability'); + + // scrolls only after search query parameter on I/O site changes + if (IS_IO && location.search) { + window.setTimeout(() => + window.scrollTo({ top: PAGE_OFFSET_HEIGHT, left: 0, behavior: 'smooth' }) + ); + + // Does not update to default behavior to persist this change + return false; + } + + // if we're not on I/O, update to default behavior + return true; +}; + +export { + wrapPageElement, + onInitialClientRender, + onClientEntry, + shouldUpdateScroll, +};