From 4a42d1b7e97ecfaf21e3b5faf4f2144d116f5150 Mon Sep 17 00:00:00 2001 From: hyesungoh Date: Sat, 31 Aug 2024 21:01:25 +0900 Subject: [PATCH] fix: combination lang input --- packages/core/components/Kbar/Search.tsx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/core/components/Kbar/Search.tsx b/packages/core/components/Kbar/Search.tsx index b10b96de..6c336461 100644 --- a/packages/core/components/Kbar/Search.tsx +++ b/packages/core/components/Kbar/Search.tsx @@ -11,19 +11,31 @@ export default function KBarSearch(props: React.InputHTMLAttributes { - query.setSearch(''); - }, [currentRootActionId, query]); + React.useEffect( + function resetWhenInit() { + query.setSearch(''); + }, + [currentRootActionId, query] + ); + + const [input, setInput] = React.useState(search); + + React.useEffect( + function updateSearch() { + query.setSearch(input); + }, + [input, query] + ); return ( { props.onChange?.(event); - query.setSearch(event.target.value); + setInput(event.target.value); }} onKeyDown={event => { if (currentRootActionId && !search && event.key === 'Backspace') {