Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp fix for scroll behavior problems #7758

Merged
merged 2 commits into from
Aug 30, 2018
Merged

Temp fix for scroll behavior problems #7758

merged 2 commits into from
Aug 30, 2018

Conversation

KyleAMathews
Copy link
Contributor

@KyleAMathews KyleAMathews commented Aug 30, 2018

Closes #7454

@@ -151,6 +156,9 @@ class GatsbyLink extends React.Component {
}
}

// Temp hack while awaiting https://github.com/reach/router/issues/119
window.__navigatingToLink = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be in

const navigate = (to, options) => {
rather than Link component to cover programmatic navigation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, and if it was moved there probably it should be in if (!option.replace) (not entirely sure here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo right, programmatic nav, forgot about that. Will switch over.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and yeah, replacing shouldn't update the scroll

if (typeof window !== `undefined`) {
window.__navigatingToLink = false
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

location.action = `push`

// Temp hack while awaiting https://github.com/reach/router/issues/119
if (window.__navigatingToLink) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this will work everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for suspecting it wouldn't?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v2] Navigating to previously visited pages with <Link> retains scroll position
3 participants