-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(router): use pagehide for iOS navigation #2537
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
Conversation
✅ Deploy Preview for vue-router canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
packages/router/src/history/html5.ts
Outdated
for (const teardown of teardowns) teardown() | ||
teardowns = [] | ||
window.removeEventListener('popstate', popStateHandler) | ||
window.removeEventListener('beforeunload', beforeUnloadListener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the beforeunload if we use pagehide
packages/router/src/history/html5.ts
Outdated
} | ||
|
||
function beforeHiddenListener() { | ||
document.hidden && beforeUnloadListener() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline this function instead
Provided another commit to fix those, thanks for the fast feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you test the ci release (should be up in a couple of minutes)
commit: |
Yup looking good ! Just installed it and the patch works fine on iOS :) Thanks ! |
fix #2536
Steps to reproduce
On iOS safari, scroll to the middle of the page, refresh, it'll go back to top instead of going back to the correct position.
What is expected?
It behaves properly in chrome for e.g., it'd restore the scroll position.
What is actually happening?
It's going back to the top of the page instead of restoring the scroll position.
The code window.addEventListener('beforeunload', beforeUnloadListener) does not trigger on iOS, we should use window.addEventListener('pagehide', ...) instead