diff --git a/modules/web/js/ballerina/views/if-else-statement-view.js b/modules/web/js/ballerina/views/if-else-statement-view.js index 509f958308..7628af9665 100644 --- a/modules/web/js/ballerina/views/if-else-statement-view.js +++ b/modules/web/js/ballerina/views/if-else-statement-view.js @@ -246,6 +246,8 @@ define(['require', 'lodash', 'log', 'property_pane_utils', './ballerina-statemen childrenView.stopListening(); }); d3.select("#_" +this._model.id).remove(); + this.getDiagramRenderingContext().getViewOfModel(this._model.getParent()).getStatementContainer() + .removeInnerDropZone(this._model); this.getBoundingBox().w(0).h(0); }; diff --git a/modules/web/js/ballerina/views/statement-container.js b/modules/web/js/ballerina/views/statement-container.js index ecd11b9252..b4c757704a 100644 --- a/modules/web/js/ballerina/views/statement-container.js +++ b/modules/web/js/ballerina/views/statement-container.js @@ -454,10 +454,14 @@ define(['lodash', 'jquery', 'd3', 'log', 'd3utils', './point', './ballerina-view this._managedStatements.splice(childStatementIndex, 1); if (this._widestStatementView === childStatementView) { - // we have deleted the widest statement. - this._widestStatementView = computeWidestStatementView(this._managedStatements, - this.diagramRenderingContext); - this._updateContainerWidth(this._widestStatementView.getBoundingBox().w()); + if(!_.isEmpty(this._managedStatements)) { + // we have deleted the widest statement. + this._widestStatementView = computeWidestStatementView(this._managedStatements, + this.diagramRenderingContext); + this._updateContainerWidth(this._widestStatementView.getBoundingBox().w()); + } else { + this._widestStatementView = undefined; + } } };