Changes methods in user list item
This commit is contained in:
parent
d2adb5ace3
commit
60e42db887
@ -86,6 +86,8 @@ class UserListItem extends Component {
|
||||
};
|
||||
|
||||
this.handleScroll = this.handleScroll.bind(this);
|
||||
this.onActionsShow = this.onActionsShow.bind(this);
|
||||
this.onActionsHide = this.onActionsHide.bind(this);
|
||||
}
|
||||
|
||||
handleScroll() {
|
||||
@ -94,7 +96,7 @@ class UserListItem extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
getUserActions() {
|
||||
getAvailableActions() {
|
||||
const {
|
||||
currentUser,
|
||||
user,
|
||||
@ -119,6 +121,24 @@ class UserListItem extends Component {
|
||||
]);
|
||||
}
|
||||
|
||||
onActionsShow() {
|
||||
const dropdown = findDOMNode(this.refs.dropdown);
|
||||
this.setState({
|
||||
contentTop: `${dropdown.offsetTop - dropdown.parentElement.parentElement.scrollTop}px`,
|
||||
isActionsOpen: true,
|
||||
active: true,
|
||||
});
|
||||
findDOMNode(this).parentElement.addEventListener('scroll', this.handleScroll, false);
|
||||
}
|
||||
|
||||
onActionsHide() {
|
||||
findDOMNode(this).parentElement.removeEventListener('scroll', this.handleScroll, false);
|
||||
this.setState({
|
||||
active: false,
|
||||
isActionsOpen: false,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
user,
|
||||
@ -143,7 +163,7 @@ class UserListItem extends Component {
|
||||
user,
|
||||
} = this.props;
|
||||
|
||||
let actions = this.getUserActions();
|
||||
let actions = this.getAvailableActions();
|
||||
let contents = (
|
||||
<div tabIndex={0} className={styles.userItemContents}>
|
||||
<UserAvatar user={user}/>
|
||||
@ -152,25 +172,6 @@ class UserListItem extends Component {
|
||||
</div>
|
||||
);
|
||||
|
||||
let onActionsShow = () => {
|
||||
const dropdown = findDOMNode(this.refs.dropdown);
|
||||
this.setState({
|
||||
contentTop: `${dropdown.offsetTop - dropdown.parentElement.parentElement.scrollTop}px`,
|
||||
isActionsOpen: true,
|
||||
active: true,
|
||||
});
|
||||
|
||||
findDOMNode(this).parentElement.addEventListener('scroll', this.handleScroll, false);
|
||||
};
|
||||
|
||||
let onActionsHide = () => {
|
||||
findDOMNode(this).parentElement.removeEventListener('scroll', this.handleScroll, false);
|
||||
this.setState({
|
||||
active: false,
|
||||
isActionsOpen: false,
|
||||
});
|
||||
};
|
||||
|
||||
if (actions.length) {
|
||||
actions = [
|
||||
(<DropdownListItem
|
||||
@ -186,8 +187,8 @@ class UserListItem extends Component {
|
||||
<Dropdown
|
||||
isOpen={this.state.isActionsOpen}
|
||||
ref="dropdown"
|
||||
onShow={onActionsShow}
|
||||
onHide={onActionsHide}
|
||||
onShow={this.onActionsShow}
|
||||
onHide={this.onActionsHide}
|
||||
className={styles.dropdown}>
|
||||
<DropdownTrigger>
|
||||
{contents}
|
||||
|
Loading…
Reference in New Issue
Block a user