From e32819e57b2dd19062455167c3b03228e3a9e071 Mon Sep 17 00:00:00 2001 From: Kavin Venkatachalam <50441969+kavinvenkatachalam@users.noreply.github.com> Date: Fri, 6 May 2022 18:11:26 +0530 Subject: [PATCH] Fixed default value issue in dropdown widget (#2988) --- frontend/src/Editor/Components/DropDown.jsx | 5 ++++- frontend/src/Editor/Components/components.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/Editor/Components/DropDown.jsx b/frontend/src/Editor/Components/DropDown.jsx index 192234f8fa..8c8e6e38cd 100644 --- a/frontend/src/Editor/Components/DropDown.jsx +++ b/frontend/src/Editor/Components/DropDown.jsx @@ -12,10 +12,12 @@ export const DropDown = function DropDown({ onComponentClick, id, component, + exposedVariables, }) { let { label, value, display_values, values } = properties; const { selectedTextColor, borderRadius, visibility, disabledState, justifyContent } = styles; const [currentValue, setCurrentValue] = useState(() => value); + const { value: exposedValue } = exposedVariables; if (!_.isArray(values)) { values = []; @@ -46,12 +48,13 @@ export const DropDown = function DropDown({ if (values?.includes(value)) { newValue = value; } + setExposedVariable('value', value); setCurrentValue(newValue); // eslint-disable-next-line react-hooks/exhaustive-deps }, [value]); useEffect(() => { - setExposedVariable('value', currentValue); + if (exposedValue !== currentValue) setExposedVariable('value', currentValue); // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentValue]); diff --git a/frontend/src/Editor/Components/components.js b/frontend/src/Editor/Components/components.js index 8e7193d203..2a30fb0560 100644 --- a/frontend/src/Editor/Components/components.js +++ b/frontend/src/Editor/Components/components.js @@ -916,7 +916,7 @@ export const componentTypes = [ justifyContent: { type: 'alignButtons', displayName: 'Align Text' }, }, exposedVariables: { - value: null, + value: 2, searchText: '', }, definition: {