Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(doc/feat) Add autofocus to docs' search bar. #15010

Closed
wants to merge 1 commit into from
Closed

(doc/feat) Add autofocus to docs' search bar. #15010

wants to merge 1 commit into from

Conversation

zzmp
Copy link
Contributor

@zzmp zzmp commented Jun 18, 2014

This is a fix for convenience for heavy keyboard users. It allows the docs to be searched without using the mouse, by giving focus to the search bar on document load.
The mouse will still need to be used to select the docs returned by the search.

This is done by giving the input.search-container an autofocus="autofocus" attribute.

This is a fix for convenience for heavy keyboard users. It allows the docs to be traversed without using the mouse, by giving focus to the search bar on document load.

This is done by giving the `input.search-container` an `autofocus="autofocus"` attribute.
@alexcrichton
Copy link
Member

You can also use the s key to highlight the search bar and the arrow keys to select between search results, but this seems fine.

@zzmp
Copy link
Contributor Author

zzmp commented Jun 18, 2014

Once I'm in the search bar, the arrows don't work. Tab works fine, though. Thanks for the tip!

@alexcrichton
Copy link
Member

Hm interesting, it appears to work in Firefox but not in Chrome or Safari. I'll open an issue.

@lilyball
Copy link
Contributor

I don't like the idea of autofocusing the search bar. Any accidental keypress will now replace what I'm looking at with search results. Notably, this will break the ability for people to use the spacebar to scroll the documentation (which I don't personally do but I know a lot of people do).

@lilyball
Copy link
Contributor

I think a better approach would be to

  1. Respond to the ? keypress by displaying a list of keyboard shortcuts (is there anything besides s to focus the search bar? I didn't even know about that one)
  2. Perhaps add a subtle help icon in the upper-right or lower-right corner of the page that can be clicked to display the same keyboard shortcuts list
  3. Consider if there are any other keyboard shortcuts that need to be added, although I think s to focus search and arrows to navigate results may be all we really need.
  4. Figure out why arrows don't work in Chrome/Safari and fix it.

@zzmp
Copy link
Contributor Author

zzmp commented Jun 18, 2014

I think a better solution would be to change the placeholder text to alert users as to the existence of s. ? should work as well (although it's broken in Chrome, where I've tried it). It is meant to display all help options.

You can also search by type, something that is not mentioned except in a hidden div.

I suggest reworking the template to change the placeholder text, and opening an issue as to why the ? does not work in Chrome (and possibly others). I agree with @kballard that adding an autofocus is not the best solution, now that I know about s, but s and other options should be more noticeable. I'll do this in another pull request right now, as it's a separate change, and we can move discussion there.

UPDATE: #15012 changes the placeholder text.

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.

3 participants