77//
88//////////////////////////////////////////////////////////////
99import React , { useCallback , useEffect , useState } from 'react' ;
10+ import _ from 'lodash' ;
1011import { styled } from '@mui/material/styles' ;
1112import { Box , useTheme } from '@mui/material' ;
1213import { PgButtonGroup , PgIconButton } from '../../../../../../static/js/components/Buttons' ;
@@ -164,7 +165,13 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor, notati
164165 isDirtyRef . current = isDirty ;
165166 setDisableButton ( 'save' , ! isDirty ) ;
166167 if ( ( isDirty || fileName ) && isSaveToolDataEnabled ( 'ERD' ) ) {
167- setSaveERDData ( { data, fileName, isDirty, toolbarPrefs} ) ;
168+ setSaveERDData ( ( prev ) => ( {
169+ ...prev ,
170+ data,
171+ fileName,
172+ isDirty,
173+ ...( toolbarPrefs !== undefined && { toolbarPrefs } ) ,
174+ } ) ) ;
168175 }
169176 } ] ,
170177 ] ;
@@ -179,8 +186,10 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor, notati
179186 } , [ ] ) ;
180187
181188 const [ saveERDData , setSaveERDData ] = useState ( null ) ;
182- useDelayDebounce ( ( { data, fileName, isDirty, toolbarPrefs} ) => {
183- saveToolData ( 'ERD' , { ...connectionInfo , 'open_file_name' :fileName , 'is_editor_dirty' : isDirty , 'preferences' : toolbarPrefs } , connectionInfo . trans_id , data ) ;
189+ useDelayDebounce ( ( saveData ) => {
190+ if ( saveData ?. data !== undefined ) {
191+ saveToolData ( 'ERD' , { ...connectionInfo , 'open_file_name' : saveData . fileName , 'is_editor_dirty' : saveData . isDirty , 'preferences' : saveData . toolbarPrefs } , connectionInfo . trans_id , saveData . data ) ;
192+ }
184193 } , saveERDData , 500 ) ;
185194
186195 useEffect ( ( ) => {
0 commit comments