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

fix(vue-app): respect scroll-margin-top when navigating with hash #9187

Merged
merged 1 commit into from May 15, 2021

Conversation

danielroe
Copy link
Member

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)

Description

This PR checks whether there is a scroll-margin-top and uses that value as offset when scrolling to the element when navigating via hash navigation, e.g. <NuxtLink to="/about#heading-3">About</NuxtLink>.

closes #9135

Checklist:

  • All new and existing tests are passing.

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2021

Codecov Report

Merging #9187 (200556d) into dev (8e2cad5) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #9187   +/-   ##
=======================================
  Coverage   65.10%   65.10%           
=======================================
  Files          94       94           
  Lines        4098     4098           
  Branches     1121     1121           
=======================================
  Hits         2668     2668           
  Misses       1152     1152           
  Partials      278      278           
Flag Coverage Δ
unittests 65.10% <ø> (ø)

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 8e2cad5...200556d. Read the comment docs.

@danielroe danielroe requested a review from clarkdo April 23, 2021 21:41
@clarkdo clarkdo merged commit 00aeff6 into dev May 15, 2021
@danielroe danielroe deleted the fix/vue-app/scroll-margin-top branch May 15, 2021 13:05
@pi0 pi0 mentioned this pull request Aug 11, 2021
@vinderman
Copy link

vinderman commented Aug 12, 2021

Hi everyone! Is it planned to support this feature on ios 11-14? These versions dont support scroll-margin-top, using snap-scroll-margin-top instead.

@danielroe danielroe added the 2.x label Jan 18, 2023
@danielroe danielroe mentioned this pull request Jan 19, 2023
@danielroe danielroe mentioned this pull request Feb 1, 2023
@awacode21
Copy link

@danielroe is this fix still available for nuxt 3 ?? i am working on latest version 3.7.4 but scroll-margin-top is ignored so my anchor links with fixed header are not working because of nuxt.

Copy link
Member Author

I would welcome a PR to implement it.

@awacode21
Copy link

@danielroe I followed your request and wanted to implement a fix. So I analysed the Nuxt code at this point and found that it already works. I just must not set the scroll-margin-top to :target, but directly to the element. Because :target is only set in the browser in the initial load with anchor, and subsequently, not with other anchors. So I adjusted my code and it is working.

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.

scroll-margin-top is ignored on links with a hash
6 participants