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

Header: in-page link targets are covered by header #219

Closed
joyously opened this issue Jul 19, 2022 · 8 comments
Closed

Header: in-page link targets are covered by header #219

joyously opened this issue Jul 19, 2022 · 8 comments

Comments

@joyously
Copy link

Now that the new header had fixed position, links to targets are hidden under it.

On a Make site, click on a sidebar link to a comment, for example, Matt's comment.
Note that you have to scroll to find the start of the comment.

You can add CSS for this (use the height of the header)
[id] { scroll-margin-top: 2em; }

@iandunn
Copy link
Member

iandunn commented Jul 19, 2022

We do have something like that already:

scroll-padding-top: var(--wp-global-header-offset, 0);

It works for me when I'm logged out, but not when logged in. Both have admin bars. It may be that the code assumes that logged-in sites don't have the admin bar, which recently changed on some sites.

@joyously
Copy link
Author

That's not the same thing, since it's on html and not on [id], and in a media query.

@iandunn
Copy link
Member

iandunn commented Jul 19, 2022

It's in a media query because the header isn't fixed on mobile.

I haven't looked into targeting html vs an ID, though, that might be part of it 👍🏻

@iandunn
Copy link
Member

iandunn commented Jul 20, 2022

Disabling the logged-out-admin-bar plugin doesn't fix it. IIRC it worked fine at launch, so if it's not the html vs id issue, it could be a recent change in Gutenberg.

@ryelle
Copy link
Contributor

ryelle commented Oct 13, 2022

I think the issue here is limited to Make sites, and there's some kind of scrollTo JS in p2 that overrides the scroll-padding-top offset that works on other sites.

For example, this anchor on developer.w.org works, but this one on another make site doesn't.

@joyously
Copy link
Author

I tried both of your links and they both have the problem. The developer one was worse for me than the Make one.
Clicking the first link shows me (Firefox):
PHP Coding Standards Coding Standards Handbook WordPress Developer Resources-38

Scrolling up a little shows how far off it was:
PHP Coding Standards Coding Standards Handbook WordPress Developer Resources-30

The second link shows me:
Miscellaneous editor changes for WordPress 6 1 – Make WordPress Core-53

Scrolling up (less than the other one):
Miscellaneous editor changes for WordPress 6 1 – Make WordPress Core-07

@ryelle
Copy link
Contributor

ryelle commented Oct 13, 2022

Oh interesting, that's correct — in-page anchors work, so on Developer, if you use the side table of contents to navigate to section, it works as expected. Same with the list of links in the make dev note. But direct links to page content don't work.

@adamwoodnz
Copy link
Contributor

This appears to be fixed now that the global header is no longer sticky. I've tested all the links in the comments on this issue.

Let me know if this is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants