diff --git a/src/KBarSearch.tsx b/src/KBarSearch.tsx index e1c1a4d..c18d663 100644 --- a/src/KBarSearch.tsx +++ b/src/KBarSearch.tsx @@ -26,6 +26,11 @@ export function KBarSearch( showing: state.visualState === VisualState.showing, })); + const [inputValue, setInputValue] = React.useState(search); + React.useEffect(() => { + query.setSearch(inputValue); + }, [inputValue, query]); + const { defaultPlaceholder, ...rest } = props; React.useEffect(() => { @@ -52,11 +57,11 @@ export function KBarSearch( aria-expanded={showing} aria-controls={KBAR_LISTBOX} aria-activedescendant={getListboxItemId(activeIndex)} - value={search} + value={inputValue} placeholder={placeholder} onChange={(event) => { props.onChange?.(event); - query.setSearch(event.target.value); + setInputValue(event.target.value); options?.callbacks?.onQueryChange?.(event.target.value); }} onKeyDown={(event) => {