Fixes default value inconsistency of dropdown widget (#361)

This commit is contained in:
Navaneeth Pk 2021-07-01 12:17:16 +05:30 committed by GitHub
parent 6423467e08
commit 4635db9102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -41,7 +41,7 @@ export const DropDown = function DropDown({
const currentValueProperty = component.definition.properties.value;
const value = currentValueProperty ? currentValueProperty.value : '';
const [currentValue, setCurrentValue] = useState(value);
const [currentValue, setCurrentValue] = useState('');
let newValue = value;
if (currentValueProperty && currentState) {
@ -52,6 +52,10 @@ export const DropDown = function DropDown({
setCurrentValue(newValue);
}, [newValue]);
useEffect(() => {
onComponentOptionChanged(component, 'value', currentValue);
}, [currentValue]);
return (
<div className="row" style={{ width, height }} onClick={() => onComponentClick(id, component)}>
<div className="col-auto">
@ -63,7 +67,7 @@ export const DropDown = function DropDown({
value={currentValue}
search={true}
onChange={(newVal) => {
onComponentOptionChanged(component, 'value', newVal);
setCurrentValue(newVal);
}}
filterOptions={fuzzySearch}
placeholder="Select.."

View file

@ -568,7 +568,7 @@ export const componentTypes = [
description: 'Select one value from options',
defaultSize: {
width: 200,
height: 30
height: 37
},
component: 'DropDown',
others: {
@ -588,7 +588,7 @@ export const componentTypes = [
},
exposedVariables: {
value: {}
value: null
},
definition: {
others: {