Skip to content

Redundant search-button-field in navbar causes toggle primary/secondary buttons to fail #999

Description

@hwhsu1231

Problem Description

Hello Sphinx Book Theme Community,

I believe some people have recently noticed the following two severe bugs in the new version of the sphinx-book-theme:

  1. An extra search-button-field appears by default in the navbar between the announcement banner and the doc page.
  2. The expand/collapse functionality of the toggle primary/secondary buttons in desktop or mobile layout stops working.

Actually, these two bugs have already been reported by others:

  1. The 1st bug was reported in #986.
  2. The 2nd bug was reported in #917, #935, and #988.

And some people have even tried submitting PRs to fix them:

  1. PR #987 to fix issue #986 (the 1st bug).
  2. PR #991 to fix issue #935 (the 2nd bug).

After thoroughly examining the source code, I have confirmed the root causes of these two bugs. Simply put:

  1. The 1st bug is caused by changes in the new version of the upstream pydata-sphinx-theme.
  2. The 2nd bug is due to an oversight in the original design of the downstream sphinx-book-theme.

Furthermore, there is a clear causal relationship between these two bugs:

Changes in the new version of the PyData theme caused the default value of navbar_persistent in the Book theme to become ["search-button-field"]. This exposed the fact that when designing the expand/collapse functionality for the primary/secondary toggle buttons, the Book theme apparently failed to consider whether it would function properly "when there are elements present in the navbar".

When do these two bugs show up?

After testing with the following commands, we can confirm that the two bugs mentioned above only start appearing from version v1.3.0:

Click to expand the testing commands
# Build the v1.4.0 documentation
VERSION=v1.4.0
git clone --branch=$VERSION [https://github.com/executablebooks/sphinx-book-theme.git](https://github.com/executablebooks/sphinx-book-theme.git) sbt-$VERSION
cd sbt-$VERSION
uv run --python 3.12 --link-mode=copy --extra doc sphinx-build -b html docs docs/_build/html
firefox docs/_build/html/index.html
cd ..

# Build the v1.3.0 documentation
VERSION=v1.3.0
git clone --branch=$VERSION [https://github.com/executablebooks/sphinx-book-theme.git](https://github.com/executablebooks/sphinx-book-theme.git) sbt-$VERSION
cd sbt-$VERSION
uv run --python 3.12 --link-mode=copy --extra doc sphinx-build -b html docs docs/_build/html
firefox docs/_build/html/index.html
cd ..

# Build the v1.2.0 documentation
VERSION=v1.2.0
git clone --branch=$VERSION [https://github.com/executablebooks/sphinx-book-theme.git](https://github.com/executablebooks/sphinx-book-theme.git) sbt-$VERSION
cd sbt-$VERSION
uv run --python 3.12 --link-mode=copy --extra doc sphinx-build -b html docs docs/_build/html
firefox docs/_build/html/index.html
cd ..

# Build the v1.1.4 documentation
VERSION=v1.1.4
git clone --branch=$VERSION [https://github.com/executablebooks/sphinx-book-theme.git](https://github.com/executablebooks/sphinx-book-theme.git) sbt-$VERSION
cd sbt-$VERSION
uv run --python 3.12 --link-mode=copy --extra doc --reinstall sphinx-build -b html docs docs/_build/html
firefox docs/_build/html/index.html

This is primarily caused by commit 8e676945 in the PyData theme (which first appeared in the 0.17.1 release). Furthermore, Book theme 1.3.0 officially began depending on PyData 0.17.1:

Book Theme PyData Theme Status
1.4.0 0.20.0 FAILED
1.3.0 0.17.1 FAILED
1.2.0 0.16.1 PASSED
1.1.4 0.15.4 PASSED

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions