Skip to content

Commit 72a4512

Browse files
committed
Revert "fix: [PROD-11887] fix wrong dirty state after clearing errors"
This reverts commit 1be17ae.
1 parent 1be17ae commit 72a4512

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/components/ScenarioParameters/components/ScenarioParametersInputs/GenericTable.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,11 @@ export const GenericTable = ({
116116

117117
// Store last parameter in a ref
118118
// Update a state is async, so, in case of multiple call of updateParameterValue in same function
119-
// parameter state value will be updated only in last call.
119+
// parameter state value will be update only in last call.
120120
// We need here to use a ref value for be sure to have the good value.
121121
const lastNewParameterValue = useRef(parameter);
122-
const dirtyState = useRef(false);
123-
124122
const updateParameterValue = useCallback(
125123
(newValuePart, shouldReset = false) => {
126-
const lastIsDirty = dirtyState.current;
127-
dirtyState.current = isDirty;
128124
const newParameterValue = {
129125
...lastNewParameterValue.current,
130126
...newValuePart,
@@ -142,14 +138,14 @@ export const GenericTable = ({
142138
// Prevent useless update of parameterValue if multiple updateParameterValue was done before
143139
if (lastNewParameterValue.current === newParameterValue) {
144140
if (shouldReset) {
145-
resetParameterValue(newParameterValue, lastIsDirty === isDirty);
141+
resetParameterValue(newParameterValue);
146142
} else {
147143
setParameterValue(newParameterValue);
148144
}
149145
}
150146
});
151147
},
152-
[resetParameterValue, setParameterValue, isDirty]
148+
[resetParameterValue, setParameterValue]
153149
);
154150

155151
const updateParameterValueWithReset = (newValuePart) => {
@@ -443,12 +439,9 @@ export const GenericTable = ({
443439
const onCellChange = updateOnFirstEdition;
444440

445441
const onClearErrors = () => {
446-
updateParameterValue(
447-
{
448-
errors: null,
449-
},
450-
true
451-
);
442+
updateParameterValue({
443+
errors: null,
444+
});
452445
};
453446

454447
const buildErrorsPanelTitle = (errorsCount, maxErrorsCount) => {

src/components/ScenarioParameters/components/ScenarioParametersTabs/ScenarioParameterInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ const ScenarioParameterInput = ({ parameterData, context }) => {
4949
}
5050
};
5151

52-
const resetParameterValue = (newDefaultValue, keepDirty = false) => {
52+
const resetParameterValue = (newDefaultValue) => {
5353
if (scenarioIdOnMount.current === getCurrentScenarioId()) {
54-
resetField(parameterData.id, { defaultValue: newDefaultValue, keepDirty });
54+
resetField(parameterData.id, { defaultValue: newDefaultValue });
5555
}
5656
};
5757

0 commit comments

Comments
 (0)