Fixed dropdown escaping the document's top
authorAlexander Ebert <ebert@woltlab.com>
Mon, 25 Jul 2016 14:00:37 +0000 (16:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 25 Jul 2016 14:00:37 +0000 (16:00 +0200)
wcfsetup/install/files/js/WCF.js

index e5f0cd8d683fc74fb87e33e6aaf7c0e83dbb1681..27716dc37a47c7f24df13810c95d261acb858c1a 100755 (executable)
@@ -1260,7 +1260,12 @@ WCF.Dropdown = {
                        }
                }
                else {
-                       if ($top + $menuDimensions.height > $(window).height() + $(document).scrollTop()) {
+                       var menuHeight = $menuDimensions.height;
+                       var scrollTop = $(document).scrollTop();
+                       
+                       // only open towards the top if there is not enough space downwards
+                       // *and* the dropdown does not overflow the document's top
+                       if (($top + menuHeight > $(window).height() + scrollTop) && ($top + scrollTop) - menuHeight > 0) {
                                $bottom = $(window).height() - $dropdownOffsets.top + 10;
                                $top = 'auto';