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

docs: keyboard only search navigation #1932

Merged
merged 7 commits into from
Mar 20, 2023
8 changes: 8 additions & 0 deletions docs/api/ApiIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ function apiSearchFocusHandler(event: KeyboardEvent): void {
} else {
apiFilter.value!.blur();
}
} else if (event.key === 'Enter') {
if (apiFilter.value !== document.activeElement) return;
if (query.value === '') return;
const item = filtered.value[0].items[0];
if (!item) return;
const header = item.headers[0];
if (!header) return;
window.location.href = item.link + '.html#' + slugify(header.anchor);
} else if (
/^[a-z]$/.test(event.key) &&
!event.altKey &&
Expand Down