Skip to content

Commit

Permalink
fix(docs): revert filter code that breaks search in docs (#2425)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmayer authored Sep 28, 2023
1 parent 9b58fe3 commit c498c09
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions docs/api/ApiIndex.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This content is mostly copied over from https://github.com/vuejs/docs/blob/main/src/api/ApiIndex.vue -->

<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue';
import { computed, ref } from 'vue';
import { slugify } from '../.vitepress/shared/utils/slugify';
import apiSearchIndex from './api-search-index.json';
import { APIGroup } from './api-types';
Expand Down Expand Up @@ -43,37 +43,6 @@ const filtered = computed(() => {
})
.filter((i) => i) as APIGroup[];
});
const apiFilter = ref<HTMLInputElement>();
function apiSearchFocusHandler(event: KeyboardEvent): void {
if (event.key === 'Escape') {
if (apiFilter.value !== document.activeElement) {
query.value = '';
} 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 + '#' + slugify(header.anchor);
} else if (
/^[a-z]$/.test(event.key) &&
!event.altKey &&
!event.ctrlKey &&
!event.shiftKey &&
!event.metaKey
) {
apiFilter.value!.focus();
}
}
onMounted(() => window.addEventListener('keydown', apiSearchFocusHandler));
onUnmounted(() => window.removeEventListener('keydown', apiSearchFocusHandler));
</script>

<template>
Expand All @@ -85,7 +54,6 @@ onUnmounted(() => window.removeEventListener('keydown', apiSearchFocusHandler));
<input
type="search"
placeholder="Enter keyword"
ref="apiFilter"
id="api-filter"
v-model="query"
/>
Expand Down

0 comments on commit c498c09

Please sign in to comment.