@@ -13,6 +13,7 @@ import { variableNameRegex } from 'utils/common/regex';
1313import toast from 'react-hot-toast' ;
1414import { Tooltip } from 'react-tooltip' ;
1515import { getGlobalEnvironmentVariables } from 'utils/collections' ;
16+ import { stripEnvVarUid } from 'utils/environments' ;
1617
1718const MIN_H = 35 * 2 ;
1819const MIN_COLUMN_WIDTH = 80 ;
@@ -187,13 +188,13 @@ const EnvironmentVariablesTable = ({
187188 } , [ environment . uid , hasDraftForThisEnv , draft ?. variables ] ) ;
188189
189190 const savedValuesJson = useMemo ( ( ) => {
190- return JSON . stringify ( environment . variables || [ ] ) ;
191+ return JSON . stringify ( ( environment . variables || [ ] ) . map ( stripEnvVarUid ) ) ;
191192 } , [ environment . variables ] ) ;
192193
193194 // Sync modified state
194195 useEffect ( ( ) => {
195196 const currentValues = formik . values . filter ( ( variable ) => variable . name && variable . name . trim ( ) !== '' ) ;
196- const currentValuesJson = JSON . stringify ( currentValues ) ;
197+ const currentValuesJson = JSON . stringify ( currentValues . map ( stripEnvVarUid ) ) ;
197198 const hasActualChanges = currentValuesJson !== savedValuesJson ;
198199 setIsModified ( hasActualChanges ) ;
199200 } , [ formik . values , savedValuesJson , setIsModified ] ) ;
@@ -202,11 +203,11 @@ const EnvironmentVariablesTable = ({
202203 useEffect ( ( ) => {
203204 const timeoutId = setTimeout ( ( ) => {
204205 const currentValues = formik . values . filter ( ( variable ) => variable . name && variable . name . trim ( ) !== '' ) ;
205- const currentValuesJson = JSON . stringify ( currentValues ) ;
206+ const currentValuesJson = JSON . stringify ( currentValues . map ( stripEnvVarUid ) ) ;
206207 const hasActualChanges = currentValuesJson !== savedValuesJson ;
207208
208209 const existingDraftVariables = hasDraftForThisEnv ? draft ?. variables : null ;
209- const existingDraftJson = existingDraftVariables ? JSON . stringify ( existingDraftVariables ) : null ;
210+ const existingDraftJson = existingDraftVariables ? JSON . stringify ( existingDraftVariables . map ( stripEnvVarUid ) ) : null ;
210211
211212 if ( hasActualChanges ) {
212213 if ( currentValuesJson !== existingDraftJson ) {
@@ -318,7 +319,8 @@ const EnvironmentVariablesTable = ({
318319 const variablesToSave = formik . values . filter ( ( variable ) => variable . name && variable . name . trim ( ) !== '' ) ;
319320 const savedValues = environment . variables || [ ] ;
320321
321- const hasChanges = JSON . stringify ( variablesToSave ) !== JSON . stringify ( savedValues ) ;
322+ // Compare without UIDs since they can be different but the actual data is the same
323+ const hasChanges = JSON . stringify ( variablesToSave . map ( stripEnvVarUid ) ) !== JSON . stringify ( savedValues . map ( stripEnvVarUid ) ) ;
322324 if ( ! hasChanges ) {
323325 toast . error ( 'No changes to save' ) ;
324326 return ;
@@ -441,8 +443,8 @@ const EnvironmentVariablesTable = ({
441443 </ tr >
442444 ) }
443445 fixedItemHeight = { 35 }
444- computeItemKey = { ( index , item ) => item . variable . uid }
445- itemContent = { ( index , { variable, index : actualIndex } ) => {
446+ computeItemKey = { ( virtualIndex , item ) => ` ${ environment . uid } - ${ item . index } ` }
447+ itemContent = { ( virtualIndex , { variable, index : actualIndex } ) => {
446448 const isLastRow = actualIndex === formik . values . length - 1 ;
447449 const isEmptyRow = ! variable . name || variable . name . trim ( ) === '' ;
448450 const isLastEmptyRow = isLastRow && isEmptyRow ;
0 commit comments