Skip to content

Commit

Permalink
Merge pull request #376 from WRidder/patch-1
Browse files Browse the repository at this point in the history
Option to prevent menu close on itemclick
  • Loading branch information
hai-cea committed Mar 3, 2015
2 parents d30b10a + bff6f78 commit ffb4baf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/js/drop-down-icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ var DropDownIcon = React.createClass({

propTypes: {
onChange: React.PropTypes.func,
menuItems: React.PropTypes.array.isRequired
menuItems: React.PropTypes.array.isRequired,
closeOnMenuItemClick: React.PropTypes.bool
},

getInitialState: function() {
return {
open: false
}
},

getDefaultProps: function() {
return {
closeOnMenuItemClick: true
}
},

componentClickAway: function() {
this.setState({ open: false });
Expand Down Expand Up @@ -51,7 +58,10 @@ var DropDownIcon = React.createClass({

_onMenuItemClick: function(e, key, payload) {
if (this.props.onChange) this.props.onChange(e, key, payload);
this.setState({ open: false });

if (this.props.closeOnMenuItemClick) {
this.setState({ open: false });
}
}

});
Expand Down

0 comments on commit ffb4baf

Please sign in to comment.