diff --git a/tildes/scss/modules/_dropdown.scss b/tildes/scss/modules/_dropdown.scss index 1e758d4..88d4420 100644 --- a/tildes/scss/modules/_dropdown.scss +++ b/tildes/scss/modules/_dropdown.scss @@ -11,6 +11,13 @@ } } + &.dropdown-bottom { + .menu { + top: auto; + bottom: 100%; + } + } + &-toggle.btn-post-action { height: auto; } diff --git a/tildes/static/js/behaviors/dropdown-toggle.js b/tildes/static/js/behaviors/dropdown-toggle.js index b1cd5a6..b998d3c 100644 --- a/tildes/static/js/behaviors/dropdown-toggle.js +++ b/tildes/static/js/behaviors/dropdown-toggle.js @@ -34,6 +34,19 @@ $.onmount(".dropdown-toggle", function() { "dropdown-right", $this.offset().left + $this.width() - $menu.width() > 0 ); + + // If the menu extends past the bottom of the viewport, or the site footer + // overlaps the menu, push the menu above the button instead. + var menuBottom = $this.offset().top + $this.height() + $menu.height(); + var viewportHeight = $(window).height(); + var scrollTop = $(document).scrollTop(); + var footerTop = $("#site-footer").offset().top; + $this + .parent() + .toggleClass( + "dropdown-bottom", + menuBottom > viewportHeight + scrollTop || menuBottom > footerTop + ); }); $(this).blur(function() {