diff --git a/frontend/src/Editor/Components/DropDown.jsx b/frontend/src/Editor/Components/DropDown.jsx index 270b923ba3..6a1870d301 100644 --- a/frontend/src/Editor/Components/DropDown.jsx +++ b/frontend/src/Editor/Components/DropDown.jsx @@ -61,7 +61,9 @@ export const DropDown = function DropDown({ const currentValueProperty = component.definition.properties.value; const value = currentValueProperty ? currentValueProperty.value : ''; - const [currentValue, setCurrentValue] = useState(''); + const [currentValue, setCurrentValue] = useState(() => + resolveReferences(currentValueProperty.value, currentState, '') + ); let newValue = value; if (currentValueProperty && currentState) { @@ -91,6 +93,15 @@ export const DropDown = function DropDown({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentValue]); + useEffect(() => { + if (selectOptions.some((e) => e.value === newValue)) { + setCurrentValue(newValue); + } else { + setCurrentValue(undefined); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [values]); + return (