diff --git a/src/app/global/mainController.js b/src/app/global/mainController.js index 3b2872868e..7aca906036 100644 --- a/src/app/global/mainController.js +++ b/src/app/global/mainController.js @@ -54,7 +54,8 @@ angular // Append dropdown menus to body var bodyScrollbarWidth, - bodyDropdownMenu; + bodyDropdownMenu, + bodyDropdownMenuParent; var dropdownHelpers = { scrollbarWidth: function () { if (!bodyScrollbarWidth) { @@ -76,7 +77,7 @@ angular }; $(window).on('show.bs.dropdown', function (e) { - var target = $(e.target); + var target = bodyDropdownMenuParent = $(e.target); if (!target.hasClass('dropdown-to-body')) { return true; } @@ -110,12 +111,24 @@ angular }); $(window).on('hide.bs.dropdown', function (e) { - var target = $(e.target); - if (!target.hasClass('dropdown-to-body')) { + if (!bodyDropdownMenu) { return true; } - target.append(bodyDropdownMenu.detach()); + $(e.target).append(bodyDropdownMenu.detach()); bodyDropdownMenu.hide(); + bodyDropdownMenu = null; + bodyDropdownMenuParent = null; + }); + + $scope.$on('removeBodyDropdownMenu', function (event, args) { + if (!bodyDropdownMenu && !bodyDropdownMenuParent) { + return true; + } + + bodyDropdownMenuParent.append(bodyDropdownMenu.detach()); + bodyDropdownMenu.hide(); + bodyDropdownMenu = null; + bodyDropdownMenuParent = null; }); }); diff --git a/src/app/settings/settingsDomainsController.js b/src/app/settings/settingsDomainsController.js index 834aebe39d..4b3aa35769 100644 --- a/src/app/settings/settingsDomainsController.js +++ b/src/app/settings/settingsDomainsController.js @@ -35,6 +35,7 @@ $scope.delete = function (i) { $scope.equivalentDomains.splice(i, 1); + $scope.$emit('removeBodyDropdownMenu'); }; $scope.addEdit = function (i) { diff --git a/src/app/settings/views/settingsDomains.html b/src/app/settings/views/settingsDomains.html index 0bc3dcd531..0ae499571a 100644 --- a/src/app/settings/views/settingsDomains.html +++ b/src/app/settings/views/settingsDomains.html @@ -9,28 +9,36 @@