@@ -116,11 +116,15 @@ 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 update only in last call.
119+ // parameter state value will be updated 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+
122124 const updateParameterValue = useCallback (
123125 ( newValuePart , shouldReset = false ) => {
126+ const lastIsDirty = dirtyState . current ;
127+ dirtyState . current = isDirty ;
124128 const newParameterValue = {
125129 ...lastNewParameterValue . current ,
126130 ...newValuePart ,
@@ -138,14 +142,14 @@ export const GenericTable = ({
138142 // Prevent useless update of parameterValue if multiple updateParameterValue was done before
139143 if ( lastNewParameterValue . current === newParameterValue ) {
140144 if ( shouldReset ) {
141- resetParameterValue ( newParameterValue ) ;
145+ resetParameterValue ( newParameterValue , lastIsDirty === isDirty ) ;
142146 } else {
143147 setParameterValue ( newParameterValue ) ;
144148 }
145149 }
146150 } ) ;
147151 } ,
148- [ resetParameterValue , setParameterValue ]
152+ [ resetParameterValue , setParameterValue , isDirty ]
149153 ) ;
150154
151155 const updateParameterValueWithReset = ( newValuePart ) => {
@@ -439,9 +443,12 @@ export const GenericTable = ({
439443 const onCellChange = updateOnFirstEdition ;
440444
441445 const onClearErrors = ( ) => {
442- updateParameterValue ( {
443- errors : null ,
444- } ) ;
446+ updateParameterValue (
447+ {
448+ errors : null ,
449+ } ,
450+ true
451+ ) ;
445452 } ;
446453
447454 const buildErrorsPanelTitle = ( errorsCount , maxErrorsCount ) => {
0 commit comments