Skip to content

Commit

Permalink
[IconMenu] Add some logic removed by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 5, 2016
1 parent 4206458 commit 2a0b320
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/menus/icon-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ const IconMenu = React.createClass({
* horizontal: [left, center, right].
*/
targetOrigin: PropTypes.origin,

/**
* Sets the delay in milliseconds before closing the
* menu when an item is clicked.
*/
touchTapCloseDelay: React.PropTypes.number,
},

contextTypes: {
Expand Down Expand Up @@ -142,6 +148,7 @@ const IconMenu = React.createClass({
vertical: 'top',
horizontal: 'left',
},
touchTapCloseDelay: 200,
};
},

Expand Down Expand Up @@ -171,6 +178,14 @@ const IconMenu = React.createClass({
}
},

componentWillUnmount() {
if (this.timerCloseId) {
clearTimeout(this.timerCloseId);
}
},

timerCloseId: undefined,

isOpen() {
return this.state.open;
},
Expand Down Expand Up @@ -214,6 +229,11 @@ const IconMenu = React.createClass({
},

_handleItemTouchTap(event, child) {
const isKeyboard = Events.isKeyboard(event);
this.timerCloseId = setTimeout(() => {
this.close(isKeyboard ? 'enter' : 'itemTap', isKeyboard);
}, this.props.touchTapCloseDelay);

this.props.onItemTouchTap(event, child);
},

Expand Down

0 comments on commit 2a0b320

Please sign in to comment.