diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index ce0d66ac5..36fe79655 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -115,6 +115,7 @@ const TextField = React.forwardRef; const useMultiTextFieldUtils = ({ + multi, multiValues = [], maxMultiValues, onMultiValueCreate, @@ -25,6 +27,12 @@ const useMultiTextFieldUtils = ({ const [values, setValues] = useState(multiValues); const [inputValue, setInputValue] = useState(''); + useEffect(() => { + if (multi) { + setValues(multiValues); + } + }, [multiValues, multi]); + const handleValueDelete = (option?: string) => { if (option) { setValues(values.filter((opt) => opt !== option)); @@ -35,6 +43,10 @@ const useMultiTextFieldUtils = ({ if (values.length > 0) { const lastItem = values[values.length - 1]; setValues(values.filter((opt) => opt !== lastItem)); + + if (onMultiValueDelete) { + onMultiValueDelete(lastItem); + } } } };