GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable search shortcuts by miketheman · Pull Request #135 · python/python-docs-theme

Conversation

@miketheman

@miketheman miketheman commented Jul 25, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@miketheman
Enable search shortcuts
049eef3
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
@ghost

ghost commented Jul 25, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miketheman

miketheman commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

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

python-docs-theme/python_docs_theme/layout.html

Line 51 in 4dbc102

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

python-docs-theme/python_docs_theme/layout.html

Line 110 in 4dbc102

<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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miketheman

miketheman commented Jul 26, 2023

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miketheman miketheman mentioned this pull request Jul 27, 2023
Use correct block, enable built-in slash keypress #141
Merged
@miketheman

miketheman commented Jul 27, 2023

Copy link
Copy Markdown
Member Author

Even simpler! #141

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk hugovk closed this in #141 Jul 29, 2023
@hugovk hugovk closed this in 788fee7 Jul 29, 2023
@miketheman
miketheman deleted the search-focus branch July 29, 2023 10:33
This was referenced Aug 29, 2023
Focus search box when pressing slash #131
Closed
Focus search box when pressing slash #153
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@miketheman @hugovk
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.