Skip to content

fix(vue-app): scrollRestoration hasn't set #8055

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

Merged
merged 2 commits into from
Sep 30, 2020

Conversation

Kolobok12309
Copy link
Contributor

Try catch block for setting window.history.scrollRestoration

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

We have a lot of bug-reports with error Cannot set property scrollRestoration of [object History] which has only a getter, this not critical setter
For fix it, i add try/catch block, while setting this prop

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

Sorry, something went wrong.

@codecov-commenter
Copy link

Codecov Report

Merging #8055 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #8055   +/-   ##
=======================================
  Coverage   68.98%   68.98%           
=======================================
  Files          91       91           
  Lines        3847     3847           
  Branches     1047     1047           
=======================================
  Hits         2654     2654           
  Misses        969      969           
  Partials      224      224           
Flag Coverage Δ
#unittests 68.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45b7838...e4d401a. Read the comment docs.

@@ -663,3 +663,9 @@ export function stripTrailingSlash (path) {
export function isSamePath (p1, p2) {
return stripTrailingSlash(p1) === stripTrailingSlash(p2)
}

export function setScrollRestoration (newVal) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't think we need this function, any benifis for not setting scrollRestoration as we already have 'scrollRestoration' in window.history checking ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'scrollRestoration' in window.history` not check for setter of this property.
Angular do this function, but i think simple try/catch simpler

@clarkdo clarkdo merged commit 79440f3 into nuxt:dev Sep 30, 2020
@clarkdo
Copy link
Member

clarkdo commented Sep 30, 2020

@Kolobok12309 Thanks!

@Kolobok12309 Kolobok12309 deleted the fix/set-scroll-restoration branch September 30, 2020 13:11
@pi0 pi0 mentioned this pull request Oct 13, 2020
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants