Skip to content

Commit 3008ccc

Browse files
authored
Merge branch 'next' into test-date-birthdate
2 parents 9beee03 + de0768c commit 3008ccc

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

docs/api/ApiIndex.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- This content is mostly copied over from https://github.com/vuejs/docs/blob/main/src/api/ApiIndex.vue -->
22

33
<script setup lang="ts">
4-
import { computed, ref } from 'vue';
4+
import { computed, onMounted, onUnmounted, ref } from 'vue';
55
import { slugify } from '../.vitepress/shared/utils/slugify';
66
import apiSearchIndex from './api-search-index.json';
77
import { APIGroup } from './api-types';
@@ -43,6 +43,29 @@ const filtered = computed(() => {
4343
})
4444
.filter((i) => i) as APIGroup[];
4545
});
46+
47+
const apiFilter = ref<HTMLInputElement>();
48+
49+
function apiSearchFocusHandler(event: KeyboardEvent): void {
50+
if (event.key === 'Escape') {
51+
if (apiFilter.value !== document.activeElement) {
52+
query.value = '';
53+
} else {
54+
apiFilter.value!.blur();
55+
}
56+
} else if (
57+
/^[a-z]$/.test(event.key) &&
58+
!event.altKey &&
59+
!event.ctrlKey &&
60+
!event.shiftKey &&
61+
!event.metaKey
62+
) {
63+
apiFilter.value!.focus();
64+
}
65+
}
66+
67+
onMounted(() => window.addEventListener('keydown', apiSearchFocusHandler));
68+
onUnmounted(() => window.removeEventListener('keydown', apiSearchFocusHandler));
4669
</script>
4770

4871
<template>
@@ -54,6 +77,7 @@ const filtered = computed(() => {
5477
<input
5578
type="search"
5679
placeholder="Enter keyword"
80+
ref="apiFilter"
5781
id="api-filter"
5882
v-model="query"
5983
/>

tsconfig.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
"esModuleInterop": true,
99
"allowJs": true,
1010
"alwaysStrict": true,
11-
// "strictNullChecks": true,
12-
// "strictBindCallApply": true,
1311
"strictFunctionTypes": true,
14-
// "strictPropertyInitialization": true,
15-
// "noImplicitAny": true,
16-
// "noImplicitThis": true,
1712
"useUnknownInCatchVariables": true,
1813
"stripInternal": true,
1914
"baseUrl": "."

0 commit comments

Comments
 (0)