diff --git a/static/scripts/app/views/widgets/dropdown.js b/static/scripts/app/views/widgets/dropdown.js index 7fc54bad52..1694cd4d73 100644 --- a/static/scripts/app/views/widgets/dropdown.js +++ b/static/scripts/app/views/widgets/dropdown.js @@ -58,10 +58,11 @@ define([ hide: function() { app.ui.currentDropdown = null; - this.$('.sf-dropdown-menu').addClass('hide'); + this.$('.sf-dropdown-menu').addClass('hide').removeAttr('style'); // `removeAttr('style')`: clear position info }, show: function() { + var $toggle = this.$('.sf-dropdown-toggle'); var $menu = this.$('.sf-dropdown-menu'); app.ui.currentDropdown = this; if (this.options.right) { @@ -69,6 +70,9 @@ define([ } else { $menu.css('left', this.options.left); } + if ($toggle.offset().top + $toggle.outerHeight(true) + $menu.outerHeight(true) > $(window).scrollTop() + $(window).height()) { + $menu.css({'bottom': $toggle.outerHeight(true) + 4}); + } this.$('.sf-dropdown-menu').removeClass('hide'); },