From 5abc85151aebbc33487909c251d6ae0ccf8fd980 Mon Sep 17 00:00:00 2001 From: Kavith Thiranga Lokuhewage Date: Sun, 12 Feb 2017 20:24:03 +0530 Subject: [PATCH] Fix if/else delete --- .../web/js/ballerina/views/if-else-statement-view.js | 2 ++ .../web/js/ballerina/views/statement-container.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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; + } } };