Skip to content

Commit

Permalink
fix: bugfix for dropdowns if initialvalue = first value
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Apr 27, 2024
1 parent 95451bd commit 96caf07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Components/DropdownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ let make = (
}, [themeObj])
React.useEffect0(() => {
if value === "" || !(options->Array.includes(value)) {
setValue(_ => options->Array.get(0)->Option.getOr(""))
setTimeout(() => {
setValue(_ => options->Array.get(0)->Option.getOr(""))
}, 0)->ignore
}
None
})
Expand Down
14 changes: 9 additions & 5 deletions src/Components/PaymentDropDownField.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ let make = (
value.value === initialValue ||
options->Array.includes(value.value)->not
) {
setValue(prev => {
...prev,
isValid: Some(true),
value: initialValue,
})
setTimeout(() => {
setValue(
prev => {
...prev,
isValid: Some(true),
value: initialValue,
},
)
}, 0)->ignore
}
None
}, [options->Array.get(0)->Option.getOr("")])
Expand Down

0 comments on commit 96caf07

Please sign in to comment.