-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Add keyboard shortcut to focus search field #31702
Conversation
I would advise against this, as it would fail https://www.w3.org/TR/WCAG21/#character-key-shortcuts |
Oh boy, didn't know there were guidelines for that. Wonder if the built-in Algolia feature mentioned helps with that at all. Also wonder if GitHub does anything like this for their shortcuts. |
Using an additional modifier key like [edit: for github itself, I would suggest a general override/ability to turn keyboard shortcuts off would make sense - showing it as part of the user account settings/preferences, and perhaps firing up a modal the first time a keyboard shortcut is fired to advise the user - maybe show the hint modal that comes up when pressing |
If an input or textarea is focused for example on the form controls page, the focus jumps to the search bar if We could make use of the native accesskey attribute, but I think it won't be clear enough which keyboard combo needs to be pressed. |
and yes, if you just register an event listener on the page as a whole, it will kick in when it shouldn't (when user's focus is actually on an input, textarea, select, etc), so would generally need extra checks in the code about "if any of these types of element are currently the |
Pushed an update here to modify the shortcut from |
if you mean the actual "once the search is focused, pressing normal keys triggers autocomplete suggestions", then that's kosher per the WCAG criterion, as you're not triggering actual functionality. in short, this now looks good |
Please give me some time to look into this and get back to you
…On Wed, Oct 28, 2020, 05:45 Mark Otto ***@***.***> wrote:
Pushed an update here to modify the shortcut from / to Ctrl /. I couldn't
figure out how to do multiple keys in Algolia's autocomplete options, so
I've stuck with the approach I started with. Thoughts?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#31702 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNL6AUBK7YJMNOX3EV3SM6HWJANCNFSM4RSUQEMQ>
.
|
Not sure what's left here, it seems to work fine like @patrickhlauke said? |
Nice this even works with |
Picks up #29834 and adds a little tag to the search input to show you can use the
/
key to focus on it. I'm not sure what bugs @MartijnCuppens was seeing based on his comment there, but this seems to work great for me locally.Preview: https://deploy-preview-31702--twbs-bootstrap.netlify.app/docs/5.0/getting-started/introduction/