feat: allow clear on multiple
This commit is contained in:
parent
e2d32471ad
commit
4325905fc4
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user