Skip to content

Hide the toggle-primary-sidebar button for pages with no navigation #924

@max-marped

Description

@max-marped

Describe the bug

context
For pages with no sidebar, i.e. pages with an empty array in html_sidebars = { "404": [], }, the toggle sidebar button is still visible.

expectation
The toggle sidebar button is hidden when no navigation is to be displayed.

bug
The toggle sidebar button is displayed. And clicking it gives the following error:

Uncaught TypeError: Cannot read properties of null (reading 'focus')
    at pydata-sphinx-theme.js:681:34

problem
This is an issue when you opt to hide the navigation tree for specific pages using the nifty setting.

Reproduce the bug

  1. Set up your sphinx book theme
  2. Add an arbitrary page to the html_sidebars setting in conf.py and set it to empty array []
html_sidebars = {
    "404": [],
}
  1. Build the documentation
  2. Open the page and look for the hamburger button on the top left hand side
  3. Click it to see the error in the browser console

List your environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions