mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Fixes default value inconsistency of dropdown widget (#361)
This commit is contained in:
parent
6423467e08
commit
4635db9102
2 changed files with 8 additions and 4 deletions
|
|
@ -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.."
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue