View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
19925 | Bug reports | Survey editing | public | 2025-01-08 11:23 | 2025-01-29 15:59 |
Reporter | 2BITS_PL | Assigned To | tibor.pacalat | ||
Priority | none | Severity | minor | ||
Status | ready for testing | Resolution | open | ||
Product Version | 6.6.x | ||||
Summary | 19925: Multiplication of dropdown-menu DOM element when switching response view mode in LimeSurvey | ||||
Description | There is an issue in LimeSurvey where the dropdown-menu DOM element multiplies during response view mode toggling (Expanded/Compact). Each toggle adds multiple instances of the dropdown-menu element to the DOM. This issue occurs in the same context as the previously reported issue with the #pjaxClickInhibitor element. The prepared fix prevents the multiplication of dropdown-menu elements while maintaining proper DOM refresh functionality. The refresh mechanism has been preserved, even though its necessity is unclear. | ||||
Steps To Reproduce | Steps to Reproduce:
Expected Behavior: Attachments:
| ||||
Tags | No tags attached. | ||||
Attached Files | fixed_multiplication_dropdownmenu.diff (1,593 bytes)
.../admin/grid/GridActionsWidget/assets/action_dropdown.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js b/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js index 6c904f3a..c9f99fb8 100644 --- a/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js +++ b/application/extensions/admin/grid/GridActionsWidget/assets/action_dropdown.js @@ -11,9 +11,11 @@ LS.actionDropdown = { document.querySelectorAll('.ls-dropdown-toggle') ); let body = document.querySelector('body'); + let uniqueId = 'dropdown-menu-' + Math.random().toString(36).substr(2, 9); dropdownElementList.map(function (dropdownToggleEl) { let dropdownMenu = dropdownToggleEl.nextElementSibling; if (dropdownMenu !== null) { + dropdownMenu.setAttribute('data-dropdown-id', uniqueId); new LS.actionDropdown.DropdownClass(dropdownToggleEl, { lsMenuElement: dropdownMenu, boundary: body, @@ -21,9 +23,16 @@ LS.actionDropdown = { strategy: 'fixed', }, }); + body.append(dropdownMenu); } }); + document.querySelectorAll('.dropdown-menu').forEach(function (menu) { + if (menu.getAttribute('data-dropdown-id') !== uniqueId) { + menu.remove(); + } + } + ); } }; | ||||
Bug heat | 6 | ||||
Complete LimeSurvey version number (& build) | 6.8.1 | ||||
I will donate to the project if issue is resolved | No | ||||
Browser | |||||
Database type & version | SQL Server 2022 | ||||
Server OS (if known) | |||||
Webserver software & version (if known) | |||||
PHP Version | v8.1.29 NTS x64 | ||||
The previous fix introduced the removal of dropdown-menu elements that did not have unique identifiers. This caused null errors in Bootstrap scripts, as the removed elements were still referenced by the library's mechanisms (e.g., _getPlacement). As a result, dropdowns stopped working. Solution
Recommendations: I’ve attached the diff file with the fix. fixed_multiplication_dropdownmenu_v2.diff (2,185 bytes)
.../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(); } ); } |
|
We tried the suggested approach. Didn't worked for us as one of the query selectors, related to removing dropdowns, was catching dropdowns which were not related to the grid. |
|
@gabrieljenik when I am on your fix branch, I am getting this issue where the page doesn't reload properly after switching back and forth (extended/compact) a couple of times. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2025-01-08 11:23 | 2BITS_PL | New Issue | |
2025-01-08 11:23 | 2BITS_PL | File Added: fixed_multiplication_dropdownmenu.diff | |
2025-01-08 14:39 | tibor.pacalat | Bug heat | 0 => 2 |
2025-01-08 14:40 | tibor.pacalat | Bug heat | 2 => 0 |
2025-01-08 14:40 | tibor.pacalat | Assigned To | => gabrieljenik |
2025-01-08 14:40 | tibor.pacalat | Status | new => assigned |
2025-01-20 12:18 | 2BITS_PL | Note Added: 81844 | |
2025-01-20 12:18 | 2BITS_PL | File Added: fixed_multiplication_dropdownmenu_v2.diff | |
2025-01-20 12:18 | 2BITS_PL | Bug heat | 0 => 2 |
2025-01-20 17:26 | gabrieljenik | Assigned To | gabrieljenik => DenisChenu |
2025-01-20 17:26 | gabrieljenik | Status | assigned => ready for code review |
2025-01-20 17:26 | gabrieljenik | Note Added: 81857 | |
2025-01-20 17:26 | gabrieljenik | Bug heat | 2 => 4 |
2025-01-20 17:27 | gabrieljenik | Note Added: 81858 | |
2025-01-29 15:14 | DenisChenu | Assigned To | DenisChenu => tibor.pacalat |
2025-01-29 15:14 | DenisChenu | Status | ready for code review => ready for testing |
2025-01-29 15:59 | tibor.pacalat | Note Added: 81920 | |
2025-01-29 15:59 | tibor.pacalat | File Added: Screen-2025-01-29-155821.mp4 | |
2025-01-29 15:59 | tibor.pacalat | Bug heat | 4 => 6 |