diff --git a/src/renderer/components/search-input/index.tsx b/src/renderer/components/search-input/index.tsx index ccb09e6e..3153e069 100644 --- a/src/renderer/components/search-input/index.tsx +++ b/src/renderer/components/search-input/index.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent } from 'react'; +import { ChangeEvent, KeyboardEvent } from 'react'; import { TextInputProps } from '@mantine/core'; import { useFocusWithin, useHotkeys, useMergedRef } from '@mantine/hooks'; import { RiSearchLine } from 'react-icons/ri'; @@ -6,7 +6,6 @@ import { TextInput } from '/@/renderer/components/input'; interface SearchInputProps extends TextInputProps { initialWidth?: number; - onChange?: (event: ChangeEvent) => void; openedWidth?: number; value?: string; } @@ -31,6 +30,14 @@ export const SearchInput = ({ ], ]); + const handleEscape = (e: KeyboardEvent) => { + if (e.code === 'Escape') { + onChange?.({ target: { value: '' } } as ChangeEvent); + ref.current.value = ''; + ref.current.blur(); + } + }; + return ( ); };