Moved code to change direction of dropdown to run when dropdown is shown (#5100)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
e9c9688b34
Коммит
a8f35c5738
@@ -21,7 +21,7 @@ export default class PostInfo extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.handleDropdownClick = this.handleDropdownClick.bind(this);
|
this.handleDropdownOpened = this.handleDropdownOpened.bind(this);
|
||||||
this.handlePermalink = this.handlePermalink.bind(this);
|
this.handlePermalink = this.handlePermalink.bind(this);
|
||||||
this.removePost = this.removePost.bind(this);
|
this.removePost = this.removePost.bind(this);
|
||||||
this.flagPost = this.flagPost.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);
|
this.editDisableAction = new DelayedAction(this.handleEditDisable);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDropdownClick(e) {
|
handleDropdownOpened() {
|
||||||
var position = $('#post-list').height() - $(e.target).offset().top;
|
this.props.handleDropdownOpened(true);
|
||||||
var dropdown = $(e.target).closest('.col__reply').find('.dropdown-menu');
|
|
||||||
|
const position = $('#post-list').height() - $(this.refs.dropdownToggle).offset().top;
|
||||||
|
const dropdown = $(this.refs.dropdown);
|
||||||
|
|
||||||
if (position < dropdown.height()) {
|
if (position < dropdown.height()) {
|
||||||
dropdown.addClass('bottom');
|
dropdown.addClass('bottom');
|
||||||
}
|
}
|
||||||
@@ -45,7 +48,7 @@ export default class PostInfo extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
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));
|
$('#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}
|
id={'post_dropdown' + this.props.post.id}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
|
ref='dropdownToggle'
|
||||||
href='#'
|
href='#'
|
||||||
className='dropdown-toggle post__dropdown theme'
|
className='dropdown-toggle post__dropdown theme'
|
||||||
type='button'
|
type='button'
|
||||||
data-toggle='dropdown'
|
data-toggle='dropdown'
|
||||||
aria-expanded='false'
|
aria-expanded='false'
|
||||||
onClick={this.handleDropdownClick}
|
|
||||||
/>
|
/>
|
||||||
<div className='dropdown-menu__content'>
|
<div className='dropdown-menu__content'>
|
||||||
<ul
|
<ul
|
||||||
|
ref='dropdown'
|
||||||
className='dropdown-menu'
|
className='dropdown-menu'
|
||||||
role='menu'
|
role='menu'
|
||||||
>
|
>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user