From c0bcaa1d7faf5e86fca1dbff2db7f9d9a9b1cfa2 Mon Sep 17 00:00:00 2001 From: arpitnath Date: Fri, 29 Oct 2021 20:29:17 +0530 Subject: [PATCH] reset t0 default value when optin values gets an update --- frontend/src/Editor/Components/DropDown.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/Editor/Components/DropDown.jsx b/frontend/src/Editor/Components/DropDown.jsx index 4a821e4e2e..0e28b9755f 100644 --- a/frontend/src/Editor/Components/DropDown.jsx +++ b/frontend/src/Editor/Components/DropDown.jsx @@ -63,6 +63,19 @@ export const DropDown = function DropDown({ const value = currentValueProperty ? currentValueProperty.value : ''; const [currentValue, setCurrentValue] = useState(''); + const [optionValues, setOptionValue] = useState(() => selectOptions); + + useEffect(() => { + const nextOptionValues = JSON.stringify(parsedValues); + const prevOptionValues = JSON.stringify(optionValues); + + if (nextOptionValues !== prevOptionValues) { + setOptionValue(() => JSON.parse(nextOptionValues)); + setCurrentValue(''); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [parsedValues]); + let newValue = value; if (currentValueProperty && currentState) { newValue = resolveReferences(currentValueProperty.value, currentState, '');