View Issue Details

This bug affects 1 person(s).
 0
IDProjectCategoryView StatusLast Update
19925Bug reportsSurvey editingpublic2025-01-08 14:40
Reporter2BITS_PL Assigned Togabrieljenik  
PrioritynoneSeverityminor 
Status assignedResolutionopen 
Product Version6.6.x 
Summary19925: 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:

  1. Go to demo.limesurvey.org.
  2. Log in as an administrator and open any survey with responses.
  3. Navigate to the response list for the selected survey.
  4. Switch the response view mode from "Expanded" to "Compact" or vice versa.
  5. Repeat the action several times.
  6. Observe in the DOM inspector that the dropdown-menu element multiplies with each toggle.

Expected Behavior:
When switching response view modes, the dropdown-menu element should be properly managed. Its duplication should involve removing previous instances so that only the current instance remains in the DOM.

Attachments:

  1. diff file containing the fixes to resolve the issue.
  2. Location of the affected file: application\extensions\admin\grid\GridActionsWidget\assets\action_dropdown.js.
TagsNo 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 heat0
Complete LimeSurvey version number (& build)6.8.1
I will donate to the project if issue is resolvedNo
Browser
Database type & versionSQL Server 2022
Server OS (if known)
Webserver software & version (if known)
PHP Versionv8.1.29 NTS x64

Users monitoring this issue

There are no users monitoring this issue.

Activities

Issue History

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