Skip to content

Fix the sidebar toggle buttons. - #226

Merged
konn merged 2 commits into
mainfrom
konn/fix-sidebar-toggle-711e
Nov 20, 2026
Merged

konn merged 2 commits into
mainfrom
konn/fix-sidebar-toggle-711e

Conversation

@konn

@konn konn commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

The visible sidebar toggle buttons in the article header did nothing.

pydata-sphinx-theme 0.17 puts a search button into navbar_persistent unless the option is set. That makes it render its own header, which has its own sidebar toggles that sphinx-book-theme hides with CSS. Both themes attach click handlers only to the first .primary-toggle / .secondary-toggle on the page, so the handlers went to the hidden header buttons instead of the visible ones.

This sets navbar_persistent: [] in html_theme_options for both books, the same default that the upstream fix (executablebooks/sphinx-book-theme#987, merged but not yet released) applies. The extra header no longer renders, so the visible buttons get the handlers directly. It also removes the top bar that only held a duplicate search field.

No search feature is lost:

  • On wide screens, the sidebar keeps its search field.
  • On narrow screens, the article header keeps its search button.
  • At any width, ⌘K (Ctrl+K outside macOS) opens search, including when the sidebar is collapsed on a wide screen.

Checked on local builds of both books with notebook execution turned off:

  • At 375px, both toggles open their sidebar dialogs, and Escape closes them.
  • At 1280px, the primary toggle collapses and restores the left sidebar.

🤖 Generated with Claude Code

konn and others added 2 commits November 19, 2026 07:48
The visible menu button had no click handler, so the sidebar stayed closed below 960px. Forward those clicks to the header button the theme already listens to.

Co-authored-by: Cursor <cursoragent@cursor.com>
pydata-sphinx-theme fills navbar_persistent with a search button unless it
is set, which renders a header with its own hidden sidebar toggles. Both
themes bind only the first .primary-toggle/.secondary-toggle, so the
visible buttons in the article header got no handler. Setting
navbar_persistent to [] stops that header from rendering, as the upstream
fix executablebooks/sphinx-book-theme#987 does, so the forwarding script
is no longer needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@konn konn changed the title Fix the sidebar toggle when the page is narrow. Fix the sidebar toggle buttons. Nov 19, 2026
@konn
konn marked this pull request as ready for review November 19, 2026 09:34

@Zengor Zengor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@konn
konn merged commit 90c36f9 into main Nov 20, 2026
25 checks passed
@konn
konn deleted the konn/fix-sidebar-toggle-711e branch November 20, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants