Skip to content

Commit

Permalink
fix: combinate lang input
Browse files Browse the repository at this point in the history
  • Loading branch information
hyesungoh committed Aug 31, 2024
1 parent 36a99bb commit db944f9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/core/components/Kbar/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@ export default function KBarSearch(props: React.InputHTMLAttributes<HTMLInputEle
}));
const { theme } = useTheme();

React.useEffect(() => {
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 (
<Input
ref={query.inputRefSetter}
{...props}
value={search}
value={input}
placeholder="Cmd (or Ctrl) + K to toggle"
onChange={event => {
props.onChange?.(event);
query.setSearch(event.target.value);
setInput(event.target.value);
}}
onKeyDown={event => {
if (currentRootActionId && !search && event.key === 'Backspace') {
Expand Down

0 comments on commit db944f9

Please sign in to comment.