Fix some issues with dropdown positioning

This commit is contained in:
Toby Zerner
2015-12-03 14:51:55 +10:30
parent 05386b1259
commit 81a1c0955b
2 changed files with 5 additions and 2 deletions

View File

@ -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) {