From a44ccd804cc786c10b574807355ba9758fe276a8 Mon Sep 17 00:00:00 2001 From: trillobite Date: Mon, 16 May 2022 18:53:59 -0700 Subject: [PATCH] bug fix: viewing a menu from menu group detail creates cicular issue unable to return to root level --- app/common/tmDetailFactory.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/common/tmDetailFactory.js b/app/common/tmDetailFactory.js index 35b477c1..69ea9612 100644 --- a/app/common/tmDetailFactory.js +++ b/app/common/tmDetailFactory.js @@ -182,21 +182,38 @@ function BaseDetail( return deferred.promise; }; + this.stateCache = ""; + // $state.stateCache = ""; this.close = function () { - var self = this; + // var self = this; this.canILeave().then(function (canILeave) { + if (canILeave) { let backState = self.$state.back.fromState.name; self.docSvc.clearDocument(); + + let goListView = () => { + // we are going back to the list so clear out the $state.data for next circular issue + $state.data = null; + self.$state.go(self.constructorArgs.listView); + } + + let goBack = () => { + $state.stateCache = self.$state.current.name; + self.$state.go(backState, $state.back.fromParams); + } + // !($state.data === backState) handle circlular issue with back button // the back state and the to state are the same if (backState && backState != "" && !($state.data === backState)) { - self.$state.go(backState, $state.back.fromParams); + if(backState == $state.stateCache) { + goListView(); + } else { + goBack(); + } } else { - // we are going back to the list so clear out the $state.data for next circular issue - $state.data = null; - self.$state.go(self.constructorArgs.listView); + goListView(); } } });