From 67ba5c2a9437e50cad99df3e42a9a948c3b79d7a Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Thu, 19 Oct 2023 19:57:47 -0700 Subject: [PATCH] Fixed calculator updating defaults bug --- .../components/src/components/Calculator/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/components/src/components/Calculator/index.tsx b/packages/components/src/components/Calculator/index.tsx index 79a7865439..4fb25e0b81 100644 --- a/packages/components/src/components/Calculator/index.tsx +++ b/packages/components/src/components/Calculator/index.tsx @@ -87,10 +87,12 @@ export const Calculator: FC = ({ calculatorStateOnFirstRender ); - const _processAllFieldCodes = async () => { + const _processAllFieldCodes = async ( + _calculatorState: CalculatorState = calculatorState + ) => { await processAllFieldCodes({ dispatch: calculatorDispatch, - state: calculatorState, + state: _calculatorState, path, calculator, environment, @@ -108,14 +110,15 @@ export const Calculator: FC = ({ calculator.hashString !== prevCalculator.hashString; if (calculatorChanged) { + const newCalculatorState = initialCalculatorState(calculator); calculatorDispatch({ type: "RESET", payload: { path: path, - state: initialCalculatorState(calculator), + state: newCalculatorState, }, }); - _processAllFieldCodes(); + _processAllFieldCodes(newCalculatorState); } else { updateFnValue({ path,