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

Adds a v shortcut to open/focus the version select #1916

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

andersonmcook
Copy link
Contributor

@andersonmcook andersonmcook commented Jun 10, 2024

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.

@@ -136,13 +143,13 @@ export function openSidebar () {
sessionStorage.setItem('sidebar_state', 'opened')
qs(SIDEBAR_TOGGLE_SELECTOR).setAttribute('aria-expanded', 'true')

requestAnimationFrame(() => {
Copy link
Contributor Author

@andersonmcook andersonmcook Jun 10, 2024

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 Promises. 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',
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@andersonmcook andersonmcook marked this pull request as ready for review June 10, 2024 02:14
@josevalim josevalim merged commit 999c9d6 into elixir-lang:main Jun 10, 2024
4 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants