ClickOutside should only toggle action when open

This commit is contained in:
Chi Vinh Le
2017-08-15 21:32:44 +07:00
parent 4cfdb6574b
commit 2b2e2f9b5f
3 changed files with 11 additions and 5 deletions
@@ -19,8 +19,10 @@ export default class Toggleable extends React.Component {
} }
close = () => { close = () => {
if (this.state.isOpen) {
this.setState({isOpen: false}); this.setState({isOpen: false});
} }
}
render() { render() {
const {children, className, ...rest} = this.props; const {children, className, ...rest} = this.props;
@@ -133,8 +133,10 @@ export default class FlagButton extends Component {
} }
handleClickOutside = () => { handleClickOutside = () => {
if (this.state.showMenu) {
this.closeMenu(); this.closeMenu();
} }
}
render () { render () {
const {getPopupMenu, flaggedByCurrentUser} = this.props; const {getPopupMenu, flaggedByCurrentUser} = this.props;
@@ -28,10 +28,12 @@ export default class PermalinkButton extends React.Component {
} }
handleClickOutside = () => { handleClickOutside = () => {
if (this.state.popoverOpen) {
this.setState({ this.setState({
popoverOpen: false popoverOpen: false
}); });
} }
}
copyPermalink = () => { copyPermalink = () => {
this.permalinkInput.select(); this.permalinkInput.select();