From 81a1c0955b81f73943ca7d559b983b4d1918cd4b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 3 Dec 2015 14:51:55 +1030 Subject: [PATCH] Fix some issues with dropdown positioning --- CHANGELOG.md | 1 + js/lib/components/Dropdown.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d418f15a..c4e1e19a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed - Fix error when sorting discussions by "oldest" (#627) +- Fix some issues with dropdown positioning ## [0.1.0-beta.4] - 2015-11-05 ### Added diff --git a/js/lib/components/Dropdown.js b/js/lib/components/Dropdown.js index ac45424cc..749f00141 100644 --- a/js/lib/components/Dropdown.js +++ b/js/lib/components/Dropdown.js @@ -47,7 +47,9 @@ export default class Dropdown extends Component { // bottom of the viewport. If it does, we will apply class to make it show // above the toggle button instead of below it. this.$().on('shown.bs.dropdown', () => { - const $menu = this.$('.Dropdown-menu').removeClass('Dropdown-menu--top Dropdown-menu--right'); + const $menu = this.$('.Dropdown-menu'); + const isRight = $menu.hasClass('Dropdown-menu--right'); + $menu.removeClass('Dropdown-menu--top Dropdown-menu--right'); $menu.toggleClass( 'Dropdown-menu--top', @@ -56,7 +58,7 @@ export default class Dropdown extends Component { $menu.toggleClass( 'Dropdown-menu--right', - $menu.offset().left + $menu.width() > $(window).scrollLeft() + $(window).width() + isRight || $menu.offset().left + $menu.width() > $(window).scrollLeft() + $(window).width() ); if (this.props.onshow) {