Skip to content

Commit eee671c

Browse files
shuuji3patak-dev
andauthored
fix: improve keyboard operability especially on search page and editor (#2730)
Co-authored-by: patak <583075+patak-dev@users.noreply.github.com>
1 parent 587c063 commit eee671c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

components/publish/PublishWidget.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ onDeactivated(() => {
283283
flex max-w-full
284284
:class="shouldExpanded ? 'min-h-30 md:max-h-[calc(100vh-200px)] sm:max-h-[calc(100vh-400px)] max-h-35 of-y-auto overscroll-contain' : ''"
285285
@keydown="stopQuestionMarkPropagation"
286+
@keydown.esc.prevent="editor?.commands.blur()"
286287
/>
287288
</div>
288289

components/search/SearchWidget.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function activate() {
8282
placeholder-text-secondary
8383
@keydown.down.prevent="shift(1)"
8484
@keydown.up.prevent="shift(-1)"
85+
@keydown.esc.prevent="input?.blur()"
8586
@keypress.enter="activate"
8687
>
8788
<button v-if="query.length" btn-action-icon text-secondary @click="query = ''; input?.focus()">

pages/[[server]]/search.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
<script setup lang="ts">
2+
const keys = useMagicKeys()
23
const { t } = useI18n()
4+
35
useHydratedHead({
46
title: () => t('nav.search'),
57
})
68
79
const search = ref<{ input?: HTMLInputElement }>()
10+
811
watchEffect(() => {
912
if (search.value?.input)
1013
search.value?.input?.focus()
1114
})
12-
onActivated(() =>
13-
search.value?.input?.focus(),
14-
)
15+
onActivated(() => search.value?.input?.focus())
1516
onDeactivated(() => search.value?.input?.blur())
17+
18+
watch(keys['/'], (v) => {
19+
// focus on input when '/' is up to avoid '/' being typed
20+
if (!v)
21+
search.value?.input?.focus()
22+
})
1623
</script>
1724

1825
<template>

0 commit comments

Comments
 (0)