From 2ac175135abd8b3ef1b3ce557276e55455710663 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 14 Jan 2019 14:06:54 +0100 Subject: [PATCH] Fix linkpicker overlay issues - manual merge of #3718 to V8 --- .../linkpicker/linkpicker.controller.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js index 58c0a01e5a..7ae464d813 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js @@ -56,26 +56,28 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController", }; if (dialogOptions.currentTarget) { - $scope.model.target = dialogOptions.currentTarget; + // clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target + $scope.model.target = angular.copy(dialogOptions.currentTarget); //if we have a node ID, we fetch the current node to build the form data if ($scope.model.target.id || $scope.model.target.udi) { //will be either a udi or an int var id = $scope.model.target.udi ? $scope.model.target.udi : $scope.model.target.id; - if (!$scope.model.target.path) { - + // is it a content link? + if (!$scope.model.target.isMedia) { + // get the content path entityResource.getPath(id, "Document").then(function (path) { $scope.model.target.path = path; oneTimeTreeSync.sync(); }); - } - // if a link exists, get the properties to build the anchor name list - contentResource.getById(id).then(function (resp) { - $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties)); - $scope.model.target.url = resp.urls[0]; - }); + // get the content properties to build the anchor name list + contentResource.getById(id).then(function (resp) { + $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties)); + $scope.model.target.url = resp.urls[0]; + }); + } } else if ($scope.model.target.url.length) { // a url but no id/udi indicates an external link - trim the url to remove the anchor/qs // only do the substring if there's a # or a ? @@ -150,6 +152,12 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController", $scope.model.target.url = mediaHelper.resolveFile(media); editorService.close(); + + // make sure the content tree has nothing highlighted + $scope.dialogTreeApi.syncTree({ + path: "-1", + tree: "content" + }); }, close: function() { editorService.close();