Fixed default value issue in dropdown widget (#2988)

This commit is contained in:
Kavin Venkatachalam 2022-05-06 18:11:26 +05:30 committed by GitHub
parent 1716213247
commit e32819e57b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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]);

View file

@ -916,7 +916,7 @@ export const componentTypes = [
justifyContent: { type: 'alignButtons', displayName: 'Align Text' },
},
exposedVariables: {
value: null,
value: 2,
searchText: '',
},
definition: {