diff --git a/client/src/components/ui/MultiSearch.tsx b/client/src/components/ui/MultiSearch.tsx index 8dda8cc8c9..64767c6442 100644 --- a/client/src/components/ui/MultiSearch.tsx +++ b/client/src/components/ui/MultiSearch.tsx @@ -1,10 +1,9 @@ import { Search, X } from 'lucide-react'; -import React, { useState, useMemo, useCallback } from 'react'; +import React, { useState, useMemo, useCallback, useRef } from 'react'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; -// This is a generic that can be added to Menu and Select components - +/** This is a generic that can be added to Menu and Select components */ export default function MultiSearch({ value, onChange, @@ -17,35 +16,57 @@ export default function MultiSearch({ className?: string; }) { const localize = useLocalize(); + const inputRef = useRef(null); + const onChangeHandler: React.ChangeEventHandler = useCallback( (e) => onChange(e.target.value), [onChange], ); + const clearSearch = () => { + onChange(''); + setTimeout(() => { + inputRef.current?.focus(); + }, 0); + }; + return (
- + -
+
+
); }