.../grid/GridActionsWidget/assets/action_dropdown.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js b/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js index c53dc16c..26144aec 100644 --- a/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js +++ b/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js @@ -11,11 +11,18 @@ LS.actionDropdown = { document.querySelectorAll('.ls-dropdown-toggle') ); let body = document.querySelector('body'); - let uniqueId = 'dropdown-menu-' + Math.random().toString(36).substr(2, 9); + let existingMenus = new Set(); + dropdownElementList.map(function (dropdownToggleEl) { let dropdownMenu = dropdownToggleEl.nextElementSibling; if (dropdownMenu !== null) { - dropdownMenu.setAttribute('data-dropdown-id', uniqueId); + if (!dropdownMenu.hasAttribute('data-dropdown-id')) { + let uniqueId = 'dropdown-menu-' + Math.random().toString(36).substr(2, 9); + dropdownMenu.setAttribute('data-dropdown-id', uniqueId); + } + + existingMenus.add(dropdownMenu.getAttribute('data-dropdown-id')); + new LS.actionDropdown.DropdownClass(dropdownToggleEl, { lsMenuElement: dropdownMenu, boundary: body, @@ -24,13 +31,14 @@ LS.actionDropdown = { }, }); - body.append(dropdownMenu); + if (!body.contains(dropdownMenu)) { + body.append(dropdownMenu); + } } }); document.querySelectorAll('.dropdown-menu').forEach(function (menu) { - if (menu.getAttribute('data-dropdown-id') !== uniqueId) { - menu.remove(); - } + if (!existingMenus.has(menu.getAttribute('data-dropdown-id'))) { + menu.remove(); } ); }