-
Notifications
You must be signed in to change notification settings - Fork 334
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
Adds a v
shortcut to open/focus the version select
#1916
Conversation
@@ -136,13 +143,13 @@ export function openSidebar () { | |||
sessionStorage.setItem('sidebar_state', 'opened') | |||
qs(SIDEBAR_TOGGLE_SELECTOR).setAttribute('aria-expanded', 'true') | |||
|
|||
requestAnimationFrame(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openSidebar
and closeSidebar
did not actually return Promise
s. I made a small update so that pressing v
with a closed sidebar will pop open the sidebar and then open/focus the version select.
@@ -34,6 +35,11 @@ export const keyboardShortcuts = [ | |||
hasModifier: true, | |||
action: searchKeyAction | |||
}, | |||
{ | |||
key: 'v', | |||
description: 'Open/focus version select', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use 'showPicker' in HTMLSelectElement.prototype
to determine the language.
if (select) { | ||
select.focus() | ||
|
||
// Prevent subsequent 'v' press from submitting form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confused me, but the v
submits the form. You can test this on the main hexdocs page for Elixir.
Click the version select without selecting a version, press escape
(the select is still focused), press v
, and it will take you to the version below your current selection.
💚 💙 💜 💛 ❤️ |
When searching for docs in a search engine, the results don't always include the latest version as the first choice. This adds a
v
shortcut that will open the version select (if the user's browser supports it, otherwise it will focus it) to make selecting versions easier.