Skip to content

Commit

Permalink
Add props to show dropdown menu
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara committed Feb 6, 2019
1 parent 5cdda58 commit 87d6191
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/Action/DropdownMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const propTypes = {
title: PropTypes.string,

dropdownClassName: PropTypes.string,
showDropdown: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -40,6 +41,7 @@ const defaultProps = {
hideDropdownIcon: false,
title: '',
dropdownClassName: '',
showDropdown: false,
};

export default class DropdownMenu extends React.PureComponent {
Expand All @@ -60,6 +62,19 @@ export default class DropdownMenu extends React.PureComponent {
window.addEventListener('click', this.handleWindowClick);
}

componentWillReceiveProps(nextProps) {
if (this.container) {
this.boundingClientRect = this.container.getBoundingClientRect();
}
const { showDropdown } = nextProps;

if (this.props.showDropdown !== showDropdown) {
this.setState({
showDropdown: nextProps.showDropdown,
});
}
}

componentWillUnmount() {
window.removeEventListener('click', this.handleWindowClick);
}
Expand Down

0 comments on commit 87d6191

Please sign in to comment.