mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Fixed default value issue in dropdown widget (#2988)
This commit is contained in:
parent
1716213247
commit
e32819e57b
2 changed files with 5 additions and 2 deletions
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -916,7 +916,7 @@ export const componentTypes = [
|
|||
justifyContent: { type: 'alignButtons', displayName: 'Align Text' },
|
||||
},
|
||||
exposedVariables: {
|
||||
value: null,
|
||||
value: 2,
|
||||
searchText: '',
|
||||
},
|
||||
definition: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue