Repository navigation
Sidebar toggle buttons missing click handlers on desktop when navbar content is present #935
Description
Describe the bug
context
When adding anything to the header navbar using navbar_*, the main "toggle sidebar" button does not work.
This is a continuation of #917. The fix unfortunately did not fix the problem.
bug
The sidebar toggle button does not work on wide viewports (≥960px) when custom content is added to the navbar because the theme only seems to attach click handlers to navbar toggle buttons (.pst-navbar-icon.sidebar-toggle), which should be in the sidebar, but those buttons are hidden at large widths. The visible article header toggle button (.header-article-item .sidebar-toggle) receives no click handler whatsoever.
problem
The main toggle sidebar button that users expect to work does nothing.
Reproduce the bug
- Set up an env with sphinx-book-theme.
- Make a minimal
index.rst(just "Hello!" is fine) and the following minimalconf.pyhtml_theme = "sphinx_book_theme" html_theme_options = {"navbar_center": ["page-toc"]} - Build and view the documentation on desktop (≥960px viewport)
- Try clicking the sidebar toggle buttons in the article header.
Here are a comprehensive list of commands to reproduce the error.
uv venv
uv pip install sphinx-book-theme==1.2.0
mkdir docs
echo "Hello" > docs/index.rst
echo "html_theme = \"sphinx_book_theme\"" > docs/conf.py
echo "html_theme_options = {\"navbar_center\": [\"page-toc\"]}" >> docs/conf.py
uv run sphinx-build docs docs/build
(cd ./docs/build && uv run python -m http.server &)
xdg-open "http://localhost:8000"You will see that clicking the Toggle Sidebar button does nothing. The checkboxes they should control remain unchanged, and if you show them via the browser inspector, checking/unchecking them works as expected. There is also no click handler registered for the button, as can be seen in the browser inspector.
proposed fix
The theme should attach handlers to ALL sidebar toggle buttons, not just navbar ones, or ensure that the correct buttons are visible based on responsive design.
workaround
Anyone happening upon this issue can manually attach click handlers to the article header toggle buttons.
document.querySelectorAll('.header-article-item .sidebar-toggle').forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
const isPrimary = button.classList.contains('primary-toggle');
const checkboxId = isPrimary ? 'pst-primary-sidebar-checkbox' : 'pst-secondary-sidebar-checkbox';
const checkbox = document.getElementById(checkboxId);
if (checkbox) {
checkbox.checked = !checkbox.checked;
}
});
});List your environment
> uv run python --version
Python 3.14.3
> uv pip freeze
accessible-pygments==0.0.5
alabaster==1.0.0
babel==2.18.0
beautifulsoup4==4.14.3
certifi==2026.2.25
charset-normalizer==3.4.5
docutils==0.22.4
idna==3.11
imagesize==2.0.0
jinja2==3.1.6
markupsafe==3.0.3
packaging==26.0
pydata-sphinx-theme==0.16.1
pygments==2.19.2
requests==2.32.5
roman-numerals==4.1.0
snowballstemmer==3.0.1
soupsieve==2.8.3
sphinx==9.1.0
sphinx-book-theme==1.2.0
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
typing-extensions==4.15.0
urllib3==2.6.3
Activity
bsipocz commentedon Sep 29, 2026
@Yann-P @flying-sheep - Has this been also resolved by #987 and/or upstream?
Yann-P commentedon Sep 29, 2026
I can't reproduce the issue on SBT latest own docs, so I guess it was related, but don't have time right now to investigate.
bsipocz commentedon Sep 29, 2026
OK, thanks. I've read up in discussion in #999 and based on your conclusion there I suppose we can also close this.
If there are some scenarios where this is still an issue we should reopen and revisit issues/PRs.