File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,8 @@ export default function ControlPanel({
146
146
}
147
147
} else if ( a . action === Action . DELETE ) {
148
148
if ( a . element === ObjectType . TABLE ) {
149
- addTable ( a . data , false ) ;
149
+ a . data . relationship . forEach ( ( x ) => addRelationship ( x , false ) ) ;
150
+ addTable ( a . data . table , false ) ;
150
151
} else if ( a . element === ObjectType . RELATIONSHIP ) {
151
152
addRelationship ( a . data , false ) ;
152
153
} else if ( a . element === ObjectType . NOTE ) {
@@ -337,7 +338,7 @@ export default function ControlPanel({
337
338
}
338
339
} else if ( a . action === Action . DELETE ) {
339
340
if ( a . element === ObjectType . TABLE ) {
340
- deleteTable ( a . data . id , false ) ;
341
+ deleteTable ( a . data . table . id , false ) ;
341
342
} else if ( a . element === ObjectType . RELATIONSHIP ) {
342
343
deleteRelationship ( a . data . id , false ) ;
343
344
} else if ( a . element === ObjectType . NOTE ) {
Original file line number Diff line number Diff line change @@ -68,12 +68,18 @@ export default function TablesContextProvider({ children }) {
68
68
const deleteTable = ( id , addToHistory = true ) => {
69
69
if ( addToHistory ) {
70
70
Toast . success ( t ( "table_deleted" ) ) ;
71
+ const rels = relationships . reduce ( ( acc , r ) => {
72
+ if ( r . startTableId === id || r . endTableId === id ) {
73
+ acc . push ( r ) ;
74
+ }
75
+ return acc ;
76
+ } , [ ] ) ;
71
77
setUndoStack ( ( prev ) => [
72
78
...prev ,
73
79
{
74
80
action : Action . DELETE ,
75
81
element : ObjectType . TABLE ,
76
- data : tables [ id ] ,
82
+ data : { table : tables [ id ] , relationship : rels } ,
77
83
message : t ( "delete_table" , { tableName : tables [ id ] } ) ,
78
84
} ,
79
85
] ) ;
You can’t perform that action at this time.
0 commit comments