Skip to content

feat: add disable_search theme option#2315

Open
PhilipSchmid wants to merge 2 commits intopydata:mainfrom
PhilipSchmid:feat/disable-search
Open

feat: add disable_search theme option#2315
PhilipSchmid wants to merge 2 commits intopydata:mainfrom
PhilipSchmid:feat/disable-search

Conversation

@PhilipSchmid
Copy link

Add a new boolean theme option disable_search (default: False) that allows users to completely remove the built-in PyData search dialog and its associated navbar button. This is useful when a third-party search addon provides its own UI and keyboard shortcut, such as the Read the Docs server-side search addon, which would otherwise conflict with PyData's dialog and Ctrl+K handler.

Changes:

  • theme.conf: add disable_search = False option
  • layout.html: wrap #pst-search-dialog in a new {% block search_dialog %} block gated on theme_disable_search. The dedicated block also gives downstream themes/overrides a clean extension point without copying the entire content block.
  • pydata-sphinx-theme.js: add null-guards in toggleSearchField() and setupSearchButtons() so both functions are safe when the dialog element is absent. Previously both functions unconditionally queried #pst-search-dialog, throwing a TypeError if the element was not in the DOM.
  • init.py: when disable_search=True, automatically remove search-button-field from navbar_persistent so the user only needs to set one option.

Closes: #202
Related: #795, #1933

@PhilipSchmid PhilipSchmid force-pushed the feat/disable-search branch from 7d868f2 to d8708f4 Compare March 5, 2026 10:32
Add a new boolean theme option `disable_search` (default: `False`) that
allows users to completely remove the built-in PyData search dialog and
its associated navbar button. This is useful when a third-party search
addon provides its own UI and keyboard shortcut, such as the Read the
Docs server-side search addon, which would otherwise conflict with
PyData's dialog and Ctrl+K handler.

Changes:
- theme.conf: add `disable_search = False` option
- layout.html: wrap `#pst-search-dialog` in a new `{% block
  search_dialog %}` block gated on `theme_disable_search`. The dedicated
  block also gives downstream themes/overrides a clean extension point
  without copying the entire `content` block.
- pydata-sphinx-theme.js: add null-guards in `toggleSearchField()` and
  `setupSearchButtons()` so both functions are safe when the dialog
  element is absent. Previously both functions unconditionally queried
  `#pst-search-dialog`, throwing a `TypeError` if the element was not
  in the DOM.
- __init__.py: when `disable_search=True`, automatically remove
  `search-button-field` from `navbar_persistent` so the user only needs
  to set one option.

Closes: pydata#202
Related: pydata#795, pydata#1933
Signed-off-by: Philip Schmid <phisch@cisco.com>
@PhilipSchmid PhilipSchmid force-pushed the feat/disable-search branch from d8708f4 to 0de9037 Compare March 5, 2026 10:36
Add a new section to docs/user_guide/search.rst explaining how to
disable the built-in search entirely using the disable_search option.
Documents what the option does automatically (removes the dialog and
strips search-button-field from navbar_persistent) and notes what it
does not touch (search-button, explicit search-field.html placements).

Signed-off-by: Philip Schmid <phisch@cisco.com>
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.

Support readthedocs-sphinx-search

1 participant