Bug #67050 [Asn]: Anchor goes under the heading navbar
| From: | cmb@php.net | Date: | Sun, 29 Apr 2018 20:48:20 +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-26954@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:
> Is there any part in particular that I should pay special
> attention to?
Yes, the third paragraph:
| [â¦] The people who are going to help you with a bug you report
| are volunteers. Not only are you not paying them to help you, but
| nobody else is either. So, to paraphrase the immortal words of
| Bill and Ted, "be excellent to them".
Replace "a bug you report" with "a bug you want to get fixed".
Previous Comments:
------------------------------------------------------------------------
[2018-04-29 15:26:32] teo8976 at gmail dot com
> However, I am still confident that it has worked and been broken in the past
It's possible that:
A) you are right, it's been alternatively fixed and broken in the past, and that may be due to
the fact that links from one part to another within a given page used to contain only the
"#segment" (e.g. href="#something", like they should be) and then they have been
changed to contain the full or partial relative url of the page (e.g.
href="this.page#something", which would break the current js code, or href="http://different.domain/same.page#something",
which would unnecessarily reload the page but work as expected, preventing the bug from being
observed)
B) OR you are wrong, it hasn't been fixed and broken, it just can be observed intermittently,
because sometimes the links contain a full URL that is different from the one of the current page
(like it links to a different mirror domain), in which case the page fully reloads and the other
part of the javascript code, which executes at page load time, always work.
Either way, my previous comment [2018-04-28 18:14 UTC] points out the exact cause of the bug and
exactly what needs to be done to fix it permanently.
------------------------------------------------------------------------
[2018-04-29 15:14:20] teo8976 at gmail dot com
> @teo8976, please read
> <https://bugs.php.net/how-to-report.php>.
Is there any part in particular that I should pay special attention to?
I'm not sure why you point me to a guide on how to report bugs, I didn't report this bug.
------------------------------------------------------------------------
[2018-04-29 00:01:43] cmb@php.net
@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>
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
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