From 9292254aa873e58eabd209109ed585d8f95a1a59 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 15 Feb 2019 14:20:42 +1100 Subject: [PATCH] Fixes umbeditornavigation.directive which doesn't listen for any changes to the navigation collection which means it can't dynamically resize or show/hide the items --- .../editor/umbeditornavigation.directive.js | 21 ++++++++----------- src/Umbraco.Web.UI.Client/src/routes.js | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js index 31976118fd..eec8455969 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditornavigation.directive.js @@ -46,18 +46,15 @@ }; function onInit() { - - // hide navigation if there is only 1 item - if (scope.navigation.length <= 1) { - scope.showNavigation = false; - } - - $timeout(function(){ - if($window && $window.innerWidth) { - calculateVisibleItems($window.innerWidth); - } - }); - + var firstRun = true; + scope.$watch("navigation.length", + (newVal, oldVal) => { + if (firstRun || newVal !== undefined && newVal !== oldVal) { + firstRun = false; + scope.showNavigation = newVal > 1; + calculateVisibleItems($window.innerWidth); + } + }); } function calculateVisibleItems(windowWidth) { diff --git a/src/Umbraco.Web.UI.Client/src/routes.js b/src/Umbraco.Web.UI.Client/src/routes.js index ecb011e3f0..001888f3ca 100644 --- a/src/Umbraco.Web.UI.Client/src/routes.js +++ b/src/Umbraco.Web.UI.Client/src/routes.js @@ -157,6 +157,7 @@ app.config(function ($routeProvider) { return; } + //TODO: Fix this special case by using components, the packager should be a component and then we just have a view for each route like normal rendering the component with the correct parameters //special case for the package section var packagePages = ["edit", "options"]; if ($routeParams.section.toLowerCase() === "packages" && $routeParams.tree.toLowerCase() === "packages" && packagePages.indexOf($routeParams.method.toLowerCase()) === -1) { @@ -164,6 +165,7 @@ app.config(function ($routeProvider) { return; } + //TODO: Fix this special case by using components, the users section should be a component and then we just have a view for each route like normal rendering the component with the correct parameters //special case for the users section var usersPages = ["user", "group"]; if ($routeParams.section.toLowerCase() === "users" && $routeParams.tree.toLowerCase() === "users" && usersPages.indexOf($routeParams.method.toLowerCase()) === -1) {