From 21e5de462d9b61e2915c3ca599d4b520b4fa6cd1 Mon Sep 17 00:00:00 2001 From: Mykyta Zakharov Date: Wed, 27 Jul 2022 01:49:51 +0300 Subject: [PATCH] Issue 12709: fixed issue with reloading of dashboard tabs. (#12730) * Issue 12709: fixed issue with reloading of dashboard tabs. * Issue-12709: fixed issue with coreBuild. --- src/Umbraco.Web.UI.Client/src/init.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/init.js b/src/Umbraco.Web.UI.Client/src/init.js index 1f8a29ee2f..e8541167dc 100644 --- a/src/Umbraco.Web.UI.Client/src/init.js +++ b/src/Umbraco.Web.UI.Client/src/init.js @@ -76,14 +76,13 @@ app.run(['$rootScope', '$route', '$location', '$cookies', 'urlHelper', 'appState /** execute code on each successful route */ $rootScope.$on('$routeChangeSuccess', function (event, current, previous) { - var toRetain = currentRouteParams ? navigationService.retainQueryStrings(currentRouteParams, current.params) : null; + var toRetain = currentRouteParams ? navigationService.retainQueryStrings(currentRouteParams.params, current.params) : null; + currentRouteParams = Utilities.copy(current); //if toRetain is not null it means that there are missing query strings and we need to update the current params if (toRetain) { $route.updateParams(toRetain); - currentRouteParams = toRetain; - } else { - currentRouteParams = Utilities.copy(current.params); + currentRouteParams ? currentRouteParams.params = toRetain : currentRouteParams = { params: toRetain }; } var deployConfig = Umbraco.Sys.ServerVariables.deploy; @@ -134,31 +133,31 @@ app.run(['$rootScope', '$route', '$location', '$cookies', 'urlHelper', 'appState //global state query strings without force re-loading views. //We can then detect if it's a location change that should force a route or not programatically. $rootScope.$on('$routeUpdate', function (event, next) { - if (!currentRouteParams) { + if (!currentRouteParams || !currentRouteParams.params) { //if there is no current route then always route which is done with reload $route.reload(); } else { - var toRetain = navigationService.retainQueryStrings(currentRouteParams, next.params); + var toRetain = navigationService.retainQueryStrings(currentRouteParams.params, next.params); //if toRetain is not null it means that there are missing query strings and we need to update the current params. if (toRetain) { $route.updateParams(toRetain); } //check if the location being changed is only due to global/state query strings which means the location change //isn't actually going to cause a route change. - if (navigationService.isRouteChangingNavigation(currentRouteParams, next.params)) { + if (navigationService.isRouteChangingNavigation(currentRouteParams.pathParams, next.pathParams)) { //The location change will cause a route change, continue the route if the query strings haven't been updated. $route.reload(); } else { //navigation is not changing but we should update the currentRouteParams to include all current parameters if (toRetain) { - currentRouteParams = toRetain; + currentRouteParams.params = toRetain; } else { - currentRouteParams = Utilities.copy(next.params); + currentRouteParams.params = Utilities.copy(next.params); } //always clear the 'sr' query string (soft redirect) if it exists - if (currentRouteParams.sr) { - currentRouteParams.sr = null; - $route.updateParams(currentRouteParams); + if (currentRouteParams.params.sr) { + currentRouteParams.params.sr = null; + $route.updateParams(currentRouteParams.params); } } }