Added work-around for page action re-creating dropdown parent
authorAlexander Ebert <ebert@woltlab.com>
Sun, 17 Jul 2016 16:21:12 +0000 (18:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 17 Jul 2016 16:21:12 +0000 (18:21 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/Dropdown/Simple.js

index 6adad84ff7c74c291e45a71a1644135d3f80950e..91d08a296ab1295f64f32c5cec80042ae3af66d9 100644 (file)
@@ -358,6 +358,23 @@ define(
                        
                        var dropdown = _dropdowns.get(targetId), preventToggle = false;
                        if (dropdown !== undefined) {
+                               // check if the dropdown is still the same, as some components (e.g. page actions)
+                               // re-create the parent of a button
+                               if (event) {
+                                       var button = event.currentTarget, parent = button.parentNode;
+                                       if (parent !== dropdown) {
+                                               parent.classList.add('dropdown');
+                                               parent.id = dropdown.id;
+                                               
+                                               // remove dropdown class and id from old parent
+                                               dropdown.classList.remove('dropdown');
+                                               dropdown.id = '';
+                                               
+                                               dropdown = parent;
+                                               _dropdowns.set(targetId, parent);
+                                       }
+                               }
+                               
                                // Repeated clicks on the dropdown button will not cause it to close, the only way
                                // to close it is by clicking somewhere else in the document or on another dropdown
                                // toggle. This is used with the search bar to prevent the dropdown from closing by