Prevent keyboard event handling for drop-down menus attached to input elements
authorAlexander Ebert <ebert@woltlab.com>
Thu, 20 Feb 2020 16:26:25 +0000 (17:26 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 20 Feb 2020 16:26:25 +0000 (17:26 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js

index 5f5594d7eed0a98c72747452df7eb3a8dd932be7..836adb47e4122e8a646bee6330e450670ea28d0c 100644 (file)
@@ -549,7 +549,13 @@ define(
                },
                
                _handleKeyDown: function(event) {
-                       if (EventKey.Enter(event) || (EventKey.Space(event) && event.currentTarget.nodeName !== 'INPUT')) {
+                       // <input> elements are not valid targets for drop-down menus. However, some developers
+                       // might still decide to combine them, in which case we try not to break things even more.
+                       if (event.currentTarget.nodeName === 'INPUT') {
+                               return;
+                       }
+                       
+                       if (EventKey.Enter(event) || EventKey.Space(event)) {
                                event.preventDefault();
                                this._toggle(event);
                        }