Skip to content

Commit

Permalink
fix: prevent auto-scroll for I/O
Browse files Browse the repository at this point in the history
  • Loading branch information
josephgregoryii committed Jan 5, 2022
1 parent 9dafd4e commit 3eaf5e6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit 3eaf5e6

Please sign in to comment.