From 0bc4ccfffb98e777eb866f69127fc2e083843ff3 Mon Sep 17 00:00:00 2001 From: Xiao Peng Date: Tue, 22 Oct 2024 20:09:10 -0700 Subject: [PATCH] fix: fix checkbox bug --- .gitignore | 4 +++- .../components/ClientAndCodeInput/index.tsx | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 4c47fea03..09d67c473 100644 --- a/.gitignore +++ b/.gitignore @@ -208,4 +208,6 @@ sync/data/ schemaspy/output # local testing -*.bat \ No newline at end of file +*.bat + +oracle-api/config/* \ No newline at end of file diff --git a/frontend/src/components/ClientAndCodeInput/index.tsx b/frontend/src/components/ClientAndCodeInput/index.tsx index e0ca0b010..7f9023a6b 100644 --- a/frontend/src/components/ClientAndCodeInput/index.tsx +++ b/frontend/src/components/ClientAndCodeInput/index.tsx @@ -38,9 +38,16 @@ const ClientAndCodeInput = ({ const clientInputRef = useRef(null); const locCodeInputRef = useRef(null); const [isDefault, setIsDefault] = useState( - () => getIsDefaultVal() + !shouldSelectDefaultValue ? false : () => getIsDefaultVal() ); + const [isChecked, setIsChecked] = useState(() => { + if (!shouldSelectDefaultValue) { + return false; + } + return checkBoxInput ? checkBoxInput.value : isDefault; + }); + const [showClientValidationStatus, setShowClientValidationStatus] = useState(true); const [showLocCodeValidationStatus, setShowLocCodeValidationStatus] = useState(false); @@ -60,7 +67,9 @@ const ClientAndCodeInput = ({ useEffect(() => { const areValsDefault = getIsDefaultVal(); - setIsDefault(areValsDefault); + if (shouldSelectDefaultValue) { + setIsDefault(areValsDefault); + } // Do not show validation status if isDefault is true if (areValsDefault) { @@ -226,6 +235,7 @@ const ClientAndCodeInput = ({ if (!checkBoxInput) { setIsDefault(checked); + setIsChecked(checked); } }; @@ -331,10 +341,6 @@ const ClientAndCodeInput = ({ } }; - let isChecked = checkBoxInput ? checkBoxInput.value : isDefault; - if (!shouldSelectDefaultValue) { - isChecked = false; - } return (