Skip to content

Commit

Permalink
issue-327: fix search input can not input chinese in react18 which us…
Browse files Browse the repository at this point in the history
…e ReactDOM.createRoot to create app
  • Loading branch information
wangliling-kkworld authored and timc1 committed Nov 17, 2023
1 parent 778ba3f commit 3e0de56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/KBarSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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) => {
Expand Down

1 comment on commit 3e0de56

@vercel
Copy link

@vercel vercel bot commented on 3e0de56 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kbar – ./

kbar-git-main-timc.vercel.app
kbar.vercel.app
kbar-timc.vercel.app

Please sign in to comment.