Skip to content

Commit

Permalink
Moved checks to close functions instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjaak Luthart committed Jun 23, 2017
1 parent 14f26af commit d77ba18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/icon-menu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,21 @@ class IconMenu extends Component {

closeMenu() {
const { onMenuClose } = this.props;
const { open } = this.state;

if (!open) {
return false;
}

this.setState({
open: false,
positioned: false
});

onMenuClose();
return onMenuClose();
}

handleClickOutside = () => {
const { open } = this.state;

if (open) {
this.closeMenu();
}
}
handleClickOutside = () => this.closeMenu()

applyCloseMenuToChildren(children) {
return React.Children.map(
Expand Down
16 changes: 8 additions & 8 deletions src/select/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ class Select extends Component {
}

closeSelect() {
this.setState({
const { open } = this.state;

if (!open) {
return false;
}

return this.setState({
open: false,
positioned: false
});
}

handleClickOutside = () => {
const { open } = this.state;

if (open) {
this.closeSelect();
}
}
handleClickOutside = () => this.closeSelect()

handleKeyUp = (event) => {
if (event.which === 27) {
Expand Down

0 comments on commit d77ba18

Please sign in to comment.