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

[preact-iso] Router: reset scroll position when navigating forwards #496

Merged
merged 5 commits into from Mar 30, 2021

Conversation

developit
Copy link
Member

@developit developit commented Mar 30, 2021

We could just call scrollTo(0, 0) in the reducer, but that would scroll pages to the top before navigation (which could be async if the component being navigated to suspends). Instead, this PR stores the "was this a forward navigation" flag in context, then checks it after the router finishes committing that navigation to see if we should scroll to the top.

Note: we'll need to rebase this once #413 is merged.

@changeset-bot
Copy link

changeset-bot bot commented Mar 30, 2021

🦋 Changeset detected

Latest commit: 9b425c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-iso Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@developit developit merged commit 8271c82 into main Mar 30, 2021
@developit developit deleted the iso-router-reset-scroll branch March 30, 2021 22:38
@github-actions github-actions bot mentioned this pull request Mar 30, 2021
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.

None yet

2 participants