@@ -181,7 +181,7 @@ export const unlinkSlots = (workspace, payload) => {
181
181
const index = outputSlot . outputElementIds . indexOf ( output . elementId )
182
182
183
183
const outputElement = workspace . entities [ output . elementId ]
184
- const newOutputElement = _removeSlotValue ( outputElement , output . slotId )
184
+ const newOutputElement = _removeSlotValue ( outputElement , output )
185
185
186
186
return Object . assign ( { } , workspace , {
187
187
entities : {
@@ -204,19 +204,41 @@ export const unlinkSlots = (workspace, payload) => {
204
204
} )
205
205
}
206
206
207
- const _removeSlotValue = ( element , slotId ) => {
207
+ const _removeSlotValue = ( element , output ) => {
208
208
var slots = { }
209
209
210
- if ( element . componentName == MAIN_BRICK ) {
211
- Object . assign ( slots , {
212
- outputSlots : element . outputSlots
213
- } )
214
- delete slots . outputSlots [ slotId ] [ 'value' ]
215
- } else {
216
- Object . assign ( slots , {
217
- inputSlots : element . inputSlots
218
- } )
219
- delete slots . inputSlots [ slotId ] [ 'value' ]
210
+ if ( output . slotId ) {
211
+ if ( element . componentName == MAIN_BRICK ) {
212
+ Object . assign ( slots , { outputSlots : element . outputSlots } )
213
+
214
+ delete slots . outputSlots [ output . slotId ] [ 'value' ]
215
+ } else {
216
+ Object . assign ( slots , { inputSlots : element . inputSlots } )
217
+
218
+ delete slots . inputSlots [ output . slotId ] [ 'value' ]
219
+ }
220
+ } else if ( output . sourceElementId ) {
221
+ if ( element . componentName == MAIN_BRICK ) {
222
+ Object . assign ( slots , { outputSlots : element . outputSlots } )
223
+
224
+ Object . keys ( element . outputSlots ) . forEach ( ( slotId ) => {
225
+ const slot = element . outputSlots [ slotId ]
226
+
227
+ if ( slot . value && slot . value . elementId == output . sourceElementId ) {
228
+ delete slots . outputSlots [ slotId ] [ 'value' ]
229
+ }
230
+ } )
231
+ } else {
232
+ Object . assign ( slots , { inputSlots : element . inputSlots } )
233
+
234
+ Object . keys ( element . inputSlots ) . forEach ( ( slotId ) => {
235
+ const slot = element . inputSlots [ slotId ]
236
+
237
+ if ( slot . value && slot . value . elementId == output . sourceElementId ) {
238
+ delete slots . inputSlots [ slotId ] [ 'value' ]
239
+ }
240
+ } )
241
+ }
220
242
}
221
243
222
244
return Object . assign ( element , { ...slots } )
0 commit comments