feat: add disable_search theme option#2315
Open
PhilipSchmid wants to merge 2 commits intopydata:mainfrom
Open
Conversation
7d868f2 to
d8708f4
Compare
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>
d8708f4 to
0de9037
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
disable_search = Falseoption#pst-search-dialogin a new{% block search_dialog %}block gated ontheme_disable_search. The dedicated block also gives downstream themes/overrides a clean extension point without copying the entirecontentblock.toggleSearchField()andsetupSearchButtons()so both functions are safe when the dialog element is absent. Previously both functions unconditionally queried#pst-search-dialog, throwing aTypeErrorif the element was not in the DOM.disable_search=True, automatically removesearch-button-fieldfromnavbar_persistentso the user only needs to set one option.Closes: #202
Related: #795, #1933