Moved code to change direction of dropdown to run when dropdown is shown (#5100)

This commit is contained in:
Harrison Healey
2017-01-23 08:14:45 -05:00
committed by enahum
parent e9c9688b34
commit a8f35c5738

View File

@@ -21,7 +21,7 @@ export default class PostInfo extends React.Component {
constructor(props) {
super(props);
this.handleDropdownClick = this.handleDropdownClick.bind(this);
this.handleDropdownOpened = this.handleDropdownOpened.bind(this);
this.handlePermalink = this.handlePermalink.bind(this);
this.removePost = this.removePost.bind(this);
this.flagPost = this.flagPost.bind(this);
@@ -32,9 +32,12 @@ export default class PostInfo extends React.Component {
this.editDisableAction = new DelayedAction(this.handleEditDisable);
}
handleDropdownClick(e) {
var position = $('#post-list').height() - $(e.target).offset().top;
var dropdown = $(e.target).closest('.col__reply').find('.dropdown-menu');
handleDropdownOpened() {
this.props.handleDropdownOpened(true);
const position = $('#post-list').height() - $(this.refs.dropdownToggle).offset().top;
const dropdown = $(this.refs.dropdown);
if (position < dropdown.height()) {
dropdown.addClass('bottom');
}
@@ -45,7 +48,7 @@ export default class PostInfo extends React.Component {
}
componentDidMount() {
$('#post_dropdown' + this.props.post.id).on('shown.bs.dropdown', () => this.props.handleDropdownOpened(true));
$('#post_dropdown' + this.props.post.id).on('shown.bs.dropdown', this.handleDropdownOpened);
$('#post_dropdown' + this.props.post.id).on('hidden.bs.dropdown', () => this.props.handleDropdownOpened(false));
}
@@ -205,15 +208,16 @@ export default class PostInfo extends React.Component {
id={'post_dropdown' + this.props.post.id}
>
<a
ref='dropdownToggle'
href='#'
className='dropdown-toggle post__dropdown theme'
type='button'
data-toggle='dropdown'
aria-expanded='false'
onClick={this.handleDropdownClick}
/>
<div className='dropdown-menu__content'>
<ul
ref='dropdown'
className='dropdown-menu'
role='menu'
>