mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-19 00:03:56 +01:00
Add keyboard shortcuts for repository file and code search (#36416)
Resolves #36417: Add GitHub-like keyboard shortcuts for repository navigation: - Press `T` to focus the "Go to file" search input - Press `S` to focus the "Search code" input - Press `Escape` to clear and unfocus search inputs --------- Signed-off-by: Micah Kepe <micahkepe@gmail.com> Signed-off-by: silverwind <me@silverwind.io> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -45,8 +45,8 @@ const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.isComposing) return;
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
clearSearch();
|
||||
nextTick(() => refElemInput.value.blur());
|
||||
return;
|
||||
}
|
||||
if (!searchQuery.value || filteredFiles.value.length === 0) return;
|
||||
@@ -145,12 +145,13 @@ watch([searchQuery, filteredFiles], async () => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="ui small input">
|
||||
<div class="ui small input global-shortcut-wrapper">
|
||||
<input
|
||||
ref="searchInput" :placeholder="placeholder" autocomplete="off"
|
||||
role="combobox" aria-autocomplete="list" :aria-expanded="searchQuery ? 'true' : 'false'"
|
||||
@input="handleSearchInput" @keydown="handleKeyDown"
|
||||
>
|
||||
<kbd data-global-init="onGlobalShortcut" data-shortcut-keys="t">T</kbd>
|
||||
</div>
|
||||
|
||||
<Teleport to="body">
|
||||
|
||||
Reference in New Issue
Block a user