summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-01-23 08:14:45 -0500
committerenahum <nahumhbl@gmail.com>2017-01-23 10:14:45 -0300
commita8f35c573875c686038d137e1663f0fd87e7f4ae (patch)
tree9a4a929cc8ab9ef225a2709224a6acd16eb777e2
parente9c9688b343049c6d461260bd15fff3486238f92 (diff)
downloadchat-a8f35c573875c686038d137e1663f0fd87e7f4ae.tar.gz
chat-a8f35c573875c686038d137e1663f0fd87e7f4ae.tar.bz2
chat-a8f35c573875c686038d137e1663f0fd87e7f4ae.zip
Moved code to change direction of dropdown to run when dropdown is shown (#5100)
-rw-r--r--webapp/components/post_view/components/post_info.jsx16
1 files changed, 10 insertions, 6 deletions
diff --git a/webapp/components/post_view/components/post_info.jsx b/webapp/components/post_view/components/post_info.jsx
index c4de46e8f..3f38bdffe 100644
--- a/webapp/components/post_view/components/post_info.jsx
+++ b/webapp/components/post_view/components/post_info.jsx
@@ -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'
>