mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
Reset to default value when option values gets an update (#1332)
* reset t0 default value when optin values gets an update * reset the default value to empty string * Revert "reset the default value to empty string" This reverts commit6845422613. * Revert "reset the default value to empty string" This reverts commit6845422613. * Reset to default value or to undefined when option values gets an update * removed unused effects
This commit is contained in:
parent
76e86bc56e
commit
7d42a0283d
1 changed files with 12 additions and 1 deletions
|
|
@ -61,7 +61,9 @@ export const DropDown = function DropDown({
|
|||
|
||||
const currentValueProperty = component.definition.properties.value;
|
||||
const value = currentValueProperty ? currentValueProperty.value : '';
|
||||
const [currentValue, setCurrentValue] = useState('');
|
||||
const [currentValue, setCurrentValue] = useState(() =>
|
||||
resolveReferences(currentValueProperty.value, currentState, '')
|
||||
);
|
||||
|
||||
let newValue = value;
|
||||
if (currentValueProperty && currentState) {
|
||||
|
|
@ -91,6 +93,15 @@ export const DropDown = function DropDown({
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentValue]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectOptions.some((e) => e.value === newValue)) {
|
||||
setCurrentValue(newValue);
|
||||
} else {
|
||||
setCurrentValue(undefined);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [values]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="dropdown-widget row g-0"
|
||||
|
|
|
|||
Loading…
Reference in a new issue