Prevent menu close on interactive dropdown close attempt
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Aug 2016 16:03:05 +0000 (18:03 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Aug 2016 16:03:05 +0000 (18:03 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/User.js

index d4f318b17088ee31323379b097e3e9f9953ff026..c55cfd294eb0da89d2c04abcb9a5d7c32b37c450 100755 (executable)
@@ -1065,6 +1065,18 @@ WCF.Dropdown.Interactive.Handler = {
                                this._dropdownMenus[instance].close();
                        }
                }
+       },
+       
+       getOpenDropdown: function () {
+               for (var instance in this._dropdownMenus) {
+                       if (this._dropdownMenus.hasOwnProperty(instance)) {
+                               if (this._dropdownMenus[instance].isOpen()) {
+                                       return this._dropdownMenus[instance];
+                               }
+                       }
+               }
+               
+               return null;
        }
 };
 
index bfe10c28aa4da5f3f466239e906f229ccdf9020a..068938786e0136b2c6fcdca6a0387ecebb4569c4 100644 (file)
@@ -46,6 +46,19 @@ define(['Core', 'EventHandler', './Abstract'], function(Core, EventHandler, UiPa
                                        }
                                }).bind(this));
                        }).bind(this));
+               },
+               
+               close: function (event) {
+                       var dropdown = WCF.Dropdown.Interactive.Handler.getOpenDropdown();
+                       if (dropdown) {
+                               event.preventDefault();
+                               event.stopPropagation();
+                               
+                               dropdown.close();
+                       }
+                       else {
+                               UiPageMenuUser._super.prototype.close.call(this, event);
+                       }
                }
        });