Commit d8708f4
committed
feat: add disable_search theme option
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
Signed-off-by: Philip Schmid <phisch@cisco.com>1 parent 213af5a commit d8708f4
File tree
4 files changed
+29
-1
lines changed- src/pydata_sphinx_theme
- assets/scripts
- theme/pydata_sphinx_theme
4 files changed
+29
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
188 | 192 | | |
189 | 193 | | |
190 | 194 | | |
| |||
301 | 305 | | |
302 | 306 | | |
303 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
304 | 312 | | |
305 | 313 | | |
306 | 314 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
0 commit comments