FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Enable search shortcuts by miketheman · Pull Request #135 · python/python-docs-theme · GitHub

Repository navigation

Enable search shortcuts - #135

Closed
miketheman wants to merge 1 commit into
python:mainfrom
miketheman:search-focus
Closed

miketheman wants to merge 1 commit into
python:mainfrom
miketheman:search-focus

Conversation

miketheman commented Jul 25, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

Enable already-existing JavaScript flag.

Included since Sphinx 4.5.0 https://www.sphinx-doc.org/en/master/changes.html#release-4-5-0-released-mar-28-2022

The doctools.js file that is served today includes the functionality - look for DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS

I think that the only piece needed is setting the config option enable_search_shortcuts = True in https://github.com/python/python-docs-theme/blob/4dbc102a556c520b10fc387821967e54dee77654/python_docs_theme/theme.conf

We inherit from default theme, which inherits classic, which inherits basic theme.

Alternative to #131

ghost commented Jul 25, 2023 •
edited by ghost
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown
Member Author

Sadly, this doesn't work 100% because we create multiple searchbox elements per page with our own layout.

<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" />

<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" />

(there's one more, I haven't hunted it down yet)

I'm guessing this would be a little more involved in restructuring the layout template to reduce the duplication, and thus enable taking advantage of their already-supplied functionality. If there's appetite for that, I'll pursue it.

hugovk commented Jul 26, 2023

Copy link
Copy Markdown
Member

Alternative to #131

Nice, I didn't know this was a Sphinx option, I'd prefer to use this than the custom JavaScript in #131. (Although there's not much JS in there.)

https://www.sphinx-doc.org/en/master/usage/theming.html says:

enable_search_shortcuts (true or false): Allow jumping to the search box with / and allow removal of search highlighting with Esc.

Defaults to True.

Does it really default to True?

We don't have / jumping, but we do have Esc clearing. Where is the Esc coming from?

Copy link
Copy Markdown
Member Author

Turns out, it does default to True, so this PR is also unnecessary!
That's why the Esc key works already.

Pressing the slash key today does in fact work, however it places the focus on the hidden mobile nav search box since it appears first in the HTML.

🤔

I wonder if we still need an explicit mobile nav, or if the signature could be changed so it still works correctly but does not appear first in the selector.

Copy link
Copy Markdown
Member Author

Even simpler! #141

hugovk closed this in #141 Jul 29, 2023
hugovk closed this in 788fee7 Jul 29, 2023
miketheman deleted the search-focus branch July 29, 2023 10:33
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL