mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Set dropdown value to invalid if value is not present in available values (#1641)
* Set dropdown value to invalid if value is not present in available values * Reset to default value if existing value is not selectable
This commit is contained in:
parent
315760b6f8
commit
248b61dee6
1 changed files with 7 additions and 3 deletions
|
|
@ -27,14 +27,18 @@ export const DropDown = function DropDown({ height, validate, properties, styles
|
|||
}, [isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentValue(value);
|
||||
setExposedVariable('value', value);
|
||||
let newValue = undefined;
|
||||
if (values?.includes(value)) newValue = value;
|
||||
|
||||
setCurrentValue(newValue);
|
||||
setExposedVariable('value', newValue);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
||||
useEffect(() => {
|
||||
let newValue = undefined;
|
||||
if (values?.includes(value)) newValue = value;
|
||||
if (values?.includes(currentValue)) newValue = currentValue;
|
||||
else if (values?.includes(value)) newValue = value;
|
||||
|
||||
setCurrentValue(newValue);
|
||||
setExposedVariable('value', newValue);
|
||||
|
|
|
|||
Loading…
Reference in a new issue