feat: allow clear on multiple

This commit is contained in:
Daniel Lautzenheiser 2023-08-31 12:21:38 -04:00
parent e2d32471ad
commit 4325905fc4

View File

@ -69,8 +69,8 @@ const Autocomplete = function <T>(
); );
const clear = useCallback(() => { const clear = useCallback(() => {
onChange(undefined); onChange(Array.isArray(value) ? [] : undefined);
}, [onChange]); }, [onChange, value]);
return ( return (
<div className="relative w-full"> <div className="relative w-full">
@ -142,7 +142,7 @@ const Autocomplete = function <T>(
aria-hidden="true" aria-hidden="true"
/> />
</Combobox.Button> </Combobox.Button>
{!required && !Array.isArray(value) ? ( {!required ? (
<IconButton variant="text" disabled={disabled} onClick={clear}> <IconButton variant="text" disabled={disabled} onClick={clear}>
<CloseIcon <CloseIcon
className={classNames( className={classNames(