From 96caf0758569c45278e3f690cefb09ec14e2ccea Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa Date: Sat, 27 Apr 2024 22:09:17 +0530 Subject: [PATCH] fix: bugfix for dropdowns if initialvalue = first value --- src/Components/DropdownField.res | 4 +++- src/Components/PaymentDropDownField.res | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Components/DropdownField.res b/src/Components/DropdownField.res index 09a54d5a6..a80304bc4 100644 --- a/src/Components/DropdownField.res +++ b/src/Components/DropdownField.res @@ -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 }) diff --git a/src/Components/PaymentDropDownField.res b/src/Components/PaymentDropDownField.res index d63b61037..4ff0141a2 100644 --- a/src/Components/PaymentDropDownField.res +++ b/src/Components/PaymentDropDownField.res @@ -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("")])