@@ -12,6 +12,7 @@ import { isMac } from "@/utils/platform";
1212import { CONTEXT_MENU_PANEL_ID } from "@/constants" ;
1313import { useShortcutsStore } from "@/stores/shortcutsStore" ;
1414import { Input } from "@headlessui/react" ;
15+ import VisibleKey from "../Common/VisibleKey" ;
1516
1617interface State {
1718 activeMenuIndex : number ;
@@ -38,6 +39,7 @@ const ContextMenu = ({ hideCoco }: ContextMenuProps) => {
3839 return state . selectedSearchContent ;
3940 } ) ;
4041 const [ searchMenus , setSearchMenus ] = useState < typeof menus > ( [ ] ) ;
42+ const searchInputRef = useRef < HTMLInputElement > ( null ) ;
4143
4244 const title = useCreation ( ( ) => {
4345 if ( selectedSearchContent ?. id === "Calculator" ) {
@@ -251,20 +253,29 @@ const ContextMenu = ({ hideCoco }: ContextMenuProps) => {
251253
252254 < div className = "-mx-3 p-2 border-t border-[#E6E6E6] dark:border-[#262626]" >
253255 { visibleContextMenu && (
254- < Input
255- autoFocus
256- placeholder = { t ( "search.contextMenu.search" ) }
257- className = "w-full bg-transparent"
258- onChange = { ( event ) => {
259- const value = event . target . value ;
260-
261- const searchMenus = menus . filter ( ( item ) => {
262- return lowerCase ( item . name ) . includes ( lowerCase ( value ) ) ;
263- } ) ;
264-
265- setSearchMenus ( searchMenus ) ;
256+ < VisibleKey
257+ shortcut = "F"
258+ shortcutClassName = "left-3"
259+ onKeyPress = { ( ) => {
260+ searchInputRef . current ?. focus ( ) ;
266261 } }
267- />
262+ >
263+ < Input
264+ ref = { searchInputRef }
265+ autoFocus
266+ placeholder = { t ( "search.contextMenu.search" ) }
267+ className = "w-full bg-transparent"
268+ onChange = { ( event ) => {
269+ const value = event . target . value ;
270+
271+ const searchMenus = menus . filter ( ( item ) => {
272+ return lowerCase ( item . name ) . includes ( lowerCase ( value ) ) ;
273+ } ) ;
274+
275+ setSearchMenus ( searchMenus ) ;
276+ } }
277+ />
278+ </ VisibleKey >
268279 ) }
269280 </ div >
270281 </ div >
0 commit comments