From: Jonathan Corbet <corbet@lwn.net>
To: Gustavo Sousa <gustavo.sousa@intel.com>, linux-doc@vger.kernel.org
Cc: gustavo.sousa@intel.com
Subject: Re: [PATCH] docs/sphinx: Fix TOC scroll hack for the home page
Date: Tue, 23 Jan 2024 14:33:52 -0700 [thread overview]
Message-ID: <87o7dbka4f.fsf@meer.lwn.net> (raw)
In-Reply-To: <20240123162157.61819-2-gustavo.sousa@intel.com>
Gustavo Sousa <gustavo.sousa@intel.com> writes:
> When on the documentation home page, there won't be any ".current"
> element since no entry from the TOC was selected yet. That results in a
> javascript error. Fix that by only trying to set the scrollTop if we
> have matches for current entries.
>
> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
> ---
> Documentation/sphinx/templates/kernel-toc.html | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/sphinx/templates/kernel-toc.html b/Documentation/sphinx/templates/kernel-toc.html
> index b58efa99df52..41f1efbe64bb 100644
> --- a/Documentation/sphinx/templates/kernel-toc.html
> +++ b/Documentation/sphinx/templates/kernel-toc.html
> @@ -12,5 +12,7 @@
> <script type="text/javascript"> <!--
> var sbar = document.getElementsByClassName("sphinxsidebar")[0];
> let currents = document.getElementsByClassName("current")
> - sbar.scrollTop = currents[currents.length - 1].offsetTop;
> + if (currents.length) {
> + sbar.scrollTop = currents[currents.length - 1].offsetTop;
> + }
> --> </script>
Interesting, that's definitely a bug. Did you stumble across this in
the console, or did it manifest in some other way for you?
Either way, I've applied this, thanks.
jon
next prev parent reply other threads:[~2024-01-23 21:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 16:21 [PATCH] docs/sphinx: Fix TOC scroll hack for the home page Gustavo Sousa
2024-01-23 21:33 ` Jonathan Corbet [this message]
2024-01-23 21:54 ` Gustavo Sousa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7dbka4f.fsf@meer.lwn.net \
--to=corbet@lwn.net \
--cc=gustavo.sousa@intel.com \
--cc=linux-doc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.