Skip to content

Commit

Permalink
Merge pull request #2344 from quantified-uncertainty/calculator-updat…
Browse files Browse the repository at this point in the history
…ing-bug

Fixed calculator updating defaults bug
  • Loading branch information
OAGr authored Oct 20, 2023
2 parents 20b52b9 + 67ba5c2 commit 13b14b8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/components/src/components/Calculator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ export const Calculator: FC<Props> = ({
calculatorStateOnFirstRender
);

const _processAllFieldCodes = async () => {
const _processAllFieldCodes = async (
_calculatorState: CalculatorState = calculatorState
) => {
await processAllFieldCodes({
dispatch: calculatorDispatch,
state: calculatorState,
state: _calculatorState,
path,
calculator,
environment,
Expand All @@ -108,14 +110,15 @@ export const Calculator: FC<Props> = ({
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,
Expand Down

3 comments on commit 13b14b8

@vercel
Copy link

@vercel vercel bot commented on 13b14b8 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 13b14b8 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 13b14b8 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.