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

refactor(vue-app): simplify scrollToTop checking #8621

Merged
merged 3 commits into from
Jan 12, 2021
Merged

Conversation

clarkdo
Copy link
Member

@clarkdo clarkdo commented Jan 11, 2021

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

Follow up #8612

Add shouldScrollToTop in router.scrollBehaviour.js

  • Simplify code
  • Not call getMatchedComponents when route is not changed

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.

@clarkdo clarkdo requested review from a team and atinux and removed request for a team January 11, 2021 17:38
@codecov-io
Copy link

Codecov Report

Merging #8621 (71505a4) into dev (3265e94) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #8621   +/-   ##
=======================================
  Coverage   66.02%   66.02%           
=======================================
  Files          92       92           
  Lines        4009     4009           
  Branches     1103     1103           
=======================================
  Hits         2647     2647           
  Misses       1095     1095           
  Partials      267      267           
Flag Coverage Δ
unittests 66.02% <ø> (ø)

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 3265e94...71505a4. Read the comment docs.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@clarkdo clarkdo merged commit 2b3eefc into dev Jan 12, 2021
@clarkdo clarkdo deleted the refactor/scroll-to-top branch January 12, 2021 09:47
@pi0 pi0 mentioned this pull request Feb 9, 2021
const { options = {} } = Pages[0]
return options.scrollToTop !== false
}
return Pages.some(({ options }) => options && options.scrollToTop)
Copy link
Contributor

@joel-wenzel joel-wenzel Oct 19, 2021

Choose a reason for hiding this comment

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

@clarkdo On line 31 here, it should be checking if options.scrollToTop !== false, similar to line 29? Otherwise the default behavior would be false if multiple components match and none specify the scrollToTop property.

I suspect it may be coded this way to return false for child routes but in that case I would think you would want to validate that the from route is included in the to route's matched routes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this works same as before change, if there’re multiple matched component, we’ll only check if there’s explicit scrollTo set which is different from single component matched scenario.

Copy link
Contributor

Choose a reason for hiding this comment

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

@clarkdo You are right. I would argue it is a bug in the prior to your PR as well. Ill create a separate issue.
The docs say child routes dont scroll to top by default but I would assume that only applies when navigating from the parent route which isnt handled.

@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

5 participants