Skip to content

Commit be695b3

Browse files
Fix docs search keyboard handling in generated template
1 parent f6e71a2 commit be695b3

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

apps/demo/src/components/DocsDefaultHeader.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ function openSearchPalette(): void {
139139
isSearchPaletteOpen.value = true
140140
}
141141
142+
function handleSearchInputKeydown(event: KeyboardEvent): void {
143+
if (event.key !== 'Enter' && event.key !== ' ') {
144+
return
145+
}
146+
147+
event.preventDefault()
148+
openSearchPalette()
149+
}
150+
142151
function handleGlobalSearchShortcut(event: KeyboardEvent): void {
143152
if (event.key.toLowerCase() !== 'k') {
144153
return
@@ -338,8 +347,7 @@ function findActiveNavValue(items: VfNavMenuItem[], pathname: string): string {
338347
leading-icon="magnifyingGlass"
339348
readonly
340349
@click="openSearchPalette"
341-
@keydown.enter.prevent="openSearchPalette"
342-
@keydown.space.prevent="openSearchPalette"
350+
@keydown="handleSearchInputKeydown"
343351
>
344352
<template #trailing>
345353
<VfBadge class="docs-header__search-shortcut">{{ searchHotkeyLabel }}</VfBadge>

packages/create-vue-ssg/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
`@codemonster-ru/vue-ssg-core@^2.1.0`.
1111
- Update the generated docs template to depend on
1212
`@codemonster-ru/vueforge-codeblock@^3.5.0`.
13+
- Keep the generated docs search input compatible with current Vue template
14+
typechecking by using a single keyboard event handler.
1315

1416
## 2.0.6 - 2026-06-03
1517

packages/create-vue-ssg/templates/docs/src/components/DocsDefaultHeader.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ function openSearchPalette(): void {
139139
isSearchPaletteOpen.value = true
140140
}
141141
142+
function handleSearchInputKeydown(event: KeyboardEvent): void {
143+
if (event.key !== 'Enter' && event.key !== ' ') {
144+
return
145+
}
146+
147+
event.preventDefault()
148+
openSearchPalette()
149+
}
150+
142151
function handleGlobalSearchShortcut(event: KeyboardEvent): void {
143152
if (event.key.toLowerCase() !== 'k') {
144153
return
@@ -338,8 +347,7 @@ function findActiveNavValue(items: VfNavMenuItem[], pathname: string): string {
338347
leading-icon="magnifyingGlass"
339348
readonly
340349
@click="openSearchPalette"
341-
@keydown.enter.prevent="openSearchPalette"
342-
@keydown.space.prevent="openSearchPalette"
350+
@keydown="handleSearchInputKeydown"
343351
>
344352
<template #trailing>
345353
<VfBadge class="docs-header__search-shortcut">{{ searchHotkeyLabel }}</VfBadge>

0 commit comments

Comments
 (0)