diff --git a/platform/commonUI/edit/bundle.json b/platform/commonUI/edit/bundle.json index 2aed41c2ee..c216a9d877 100644 --- a/platform/commonUI/edit/bundle.json +++ b/platform/commonUI/edit/bundle.json @@ -59,7 +59,7 @@ "glyph": "Z", "name": "Remove", "description": "Remove this object from its containing object.", - "depends": [ "$q" ] + "depends": [ "$q", "navigationService" ] }, { "key": "save", diff --git a/platform/commonUI/edit/src/actions/RemoveAction.js b/platform/commonUI/edit/src/actions/RemoveAction.js index fbf47d22d9..f0ed09d161 100644 --- a/platform/commonUI/edit/src/actions/RemoveAction.js +++ b/platform/commonUI/edit/src/actions/RemoveAction.js @@ -40,7 +40,7 @@ define( * @constructor * @memberof module:editor/actions/remove-action */ - function RemoveAction($q, context) { + function RemoveAction($q, navigationService, context) { var object = (context || {}).domainObject; /** @@ -69,6 +69,15 @@ define( return persistence && persistence.persist(); } + function checkCurrentObjectNavigation(parent) { + var currParent = navigationService.getNavigation().getCapability('context').getParent() + if(currParent.getId() === parent.getId()) { + navigationService.setNavigation(parent); + } else { + console.log("ALL GOOD"); + } + } + /** * Remove the object from its parent, as identified by its context * capability. @@ -77,6 +86,9 @@ define( */ function removeFromContext(contextCapability) { var parent = contextCapability.getParent(); + // Goes to parent if deleting currently + // opened object + checkCurrentObjectNavigation(parent); $q.when( parent.useCapability('mutation', doMutate) ).then(function () {