Bug #67050 [Asn]: Anchor goes under the heading navbar
| From: | cmb@php.net | Date: | Sun, 29 Apr 2018 00:01:45 +0000 |
| Subject: | Bug #67050 [Asn]: Anchor goes under the heading navbar | ||
| References: | 1 | Groups: | php.webmaster |
| Request: | Send a blank email to php-webmaster+get-26950@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67050&edit=1
ID: 67050
Updated by: cmb@php.net
Reported by: adrien dot dupuis at gmail dot com
Summary: Anchor goes under the heading navbar
Status: Assigned
Type: Bug
Package: Website problem
Operating System: Irrelevant
PHP Version: Irrelevant
Assigned To: levim
Block user comment: N
Private report: N
New Comment:
@teo8976, please read <https://bugs.php.net/how-to-report.php>.
Thanks!
For what it is worth, the most simple solution regarding jumping
to anchors on pages with a fixed menu at the top of the page, is
to set an appropriate margin-bottom for the *html* element.
However, that does not work well for jQuery[1] (I've never
mentioned any issue regarding vanilla JS, though).
[1] <https://github.com/jquery/jquery/issues/3676>
Previous Comments:
------------------------------------------------------------------------
[2018-04-28 18:27:40] levim@php.net
Your attitude is unnecessary. Yes, we have problems, and yes, we've had them for a long time.
Open a pull request that fixes it without breaking other things or just leave it alone and someone
else, eventually, will fix it.
You are right; I was going directly to the link. However, I am still confident that it has worked
and been broken in the past; the solution is probably not far off from what's there.
------------------------------------------------------------------------
[2018-04-28 18:14:37] teo8976 at gmail dot com
This seems to be the code that is supposed to do the job:
////////////////////////////////
document.body.addEventListener("click", function (e) {
if (e.target && e.target.nodeName === "A") {
var href = e.target.getAttribute("href");
if (href && href[0] === "#") {
var id = href.slice(1);
var target = document.getElementById(id);
// temporarily remove the id="" attribute so that the UA's
// default scrolling is prevented
target.id = "";
if (target) {
PHP_NET.scrollElementIntoView(target, null, function () {
// restore the id="" attribute
target.id = id;
});
}
}
}
});
////////////////////////////////
This would work if the links were like <a href="#something">, but instead, they are
like <a href="relative.path.of.current.page#something">
so, the javascript code does nothing at all in this case.
------------------------------------------------------------------------
[2018-04-28 18:03:19] teo8976 at gmail dot com
> There is a JavaScript solution in-place and it works for me in Chrome on Windows
When you say it works for you, are you testing by going directly to a deep-link url like http://www.php.net/manual/fr/class.domdocument.php#domdocument.props.actualencoding
(that does NOT reproduce the issue), or are you following the original report instructions, which
are:
1 - first go to a page without the #segment part, e.g.
http://be2.php.net/manual/fr/class.domdocument.php
2 - then click on a link that points to a #something anchor within the same page, e.g. the link to
"$actualEncoding"?
Note that, in order to properly test for the issue, you need to make sure that the link is actually
internal to the same page, with only the #segment part being different (I notice that sometimes,
depending on language and stuff, the links might actually point to a copy of the same page on a
different domain).
> what browser are you using?
Chrome on Linux
> Or are you disabling/blocking JavaScript?
LOL no, of course not. (btw if this has to be handled by javascript one should seriously question
whether something is very badly designed at a deeper level - not saying that I'd expect any
webpage to work with javascript disabled these days, but it just shouldn't be necessary to use
javascript for this kind of things. Anyway that's another story).
------------------------------------------------------------------------
[2018-04-28 17:40:38] levim@php.net
> If you are not going to fix it, it should be assigned to someone else.
Who?
By the way this issue has been fixed and then broken numerous times. There is a JavaScript solution
in-place and it works for me in Chrome on Windows - what browser are you using? Or are you
disabling/blocking JavaScript?
------------------------------------------------------------------------
[2018-04-28 17:05:21] teo8976 at gmail dot com
> do you think I get paid for this or something?
Given the way you ask, I guess not, and I don't care. If you are not going to fix it, it should
be assigned to someone else.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=67050
--
Edit this bug report at https://bugs.php.net/bug.php?id=67050&edit=1