-
Notifications
You must be signed in to change notification settings - Fork 326
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
Secondary Sidebar TOC active nav element not changing as expected #1724
Comments
Debugging details(1) The active CSS class is not added correctlyThis seems to be related to the
(omitted Note that that (2) The active class is added by Bootstrap 5Looking at the
Here is a link to Bootstrap 5.2 docs explaining scrollspy. (3) activate.bs.scrollspy is only triggered onceWhen I edit function addTOCInteractivity() {
window.addEventListener("activate.bs.scrollspy", function () {
const navLinks = document.querySelectorAll(".bd-toc-nav a");
console.log(navLinks) // <--- added
navLinks.forEach((navLink) => {
navLink.parentElement.classList.remove("active");
});
const activeNavLinks = document.querySelectorAll(".bd-toc-nav a.active");
activeNavLinks.forEach((navLink) => {
navLink.parentElement.classList.add("active");
});
});
} I can see the event triggering only once when scrolling down the page, at the "A list of functions" section title. The event does not trigger on any other title or when scrolling upwards to "A list of functions" (from bottom of page). |
It is likely that this is related to how scrollspy works on Bootstrap 5.2. See: https://github.com/twbs/bootstrap/issues (Issue 36431). There are fixes proposed on the page but as I'm not so familiar with front end development it might be better that someone else took a look on it. |
Thanks for flagging this @fohrloop. We will look into this and circle back with our findings. @gabalafou would you be able to look into this? |
If the IDs contain dots, then twbs/bootstrap#39248 is perhaps the culprit. |
You are right @Charlie-XIAO that seems to be the cause of this behaviour. So in that spirit will close the issue and hope this will be resolved upstream. |
Fix the sidebar TOC =================== The sidebar TOC had a bug. This comes from sphinx-book-theme, which uses the pydata-sphinx-theme. I filed a bug report in pydata/pydata-sphinx-theme#1724 but that was closed as the root cause is likely in the Bootstrap scroll spy (upstream issue). The bug causes the right side sidebar TOC to not show fully on the API reference page, "active" <ul> or <li> elements are shown, and this activation does not work at all on the API Reference page. This could have probably been circumvented in a more elegant way but I decided to take a shortcut and 1. Disable the Bootstrap scroll spy on the API reference page 2. Activate all nav > ul > li items (second level children) so two levels of the TOC is always shown on the API reference page. The logic is in the wakepy.js. This can be removed if the issue is fixed in pydata-sphinx-theme or in sphinx-book-theme. Remove NamedTuple noise ======================= The NamedTuples caused noise in the API Reference page. Namely, there was extra "Alias for field number X" (X is a number of the field) items in the docs, for everything that is subclass of NamedTuple. This fix uses temporarily numpydoc 1.7.0rc0.dev0 directly from https://github.com/numpy/numpydoc.git@46f532a824639a97479039fc122533915cdfa10f When numpydoc 1.7.0 is released, can update pyproject.toml to use that.
It's still not working correctly. We have adopted this theme in falcon, but while it seem that the active section changes while scrolling the first section is never selected. Example: https://falcon.readthedocs.io/en/latest/api/util.html Other example of the same behaviour, without . in the href: |
Unfortunately, as this is coming directly from bootstrap and the issue remains open and unaddressed, there is not much we can do ATM but wait until this is fixed upstream. |
shame. it's quite annoying once you notice it |
Problem description
I noticed strange behavior with the secondary sidebar TOC highlighter, which shows the "active" part of the page. For some reason, I see that occasionally the "active" part is not highlighted in the sidebar TOC. What I'm referring is this highlight:
Example of problem (gif)
This is perhaps easier to explain with a short video. See that only the A list of functions part is ever "activated" for the highlight.
What I would expect
All the items in the following list would be activated, one by one:
Reproducing the problem
sphinx-autobuild docs/source/ docs/build/ -a -E
index.rst
:I've not yet found why this happens. Could this be a bug or is it related to some configuration value?
Tested with
The text was updated successfully, but these errors were encountered: