Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/components/icon-menus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class IconMenus extends React.Component {
type: 'number',
header: 'default: 200',
desc: 'Sets the delay in milliseconds before closing the menu when an item is clicked.'
},
{
name: 'closeOnItemTouchTap',
type: 'bool',
header: 'optional',
desc: 'If false, menu will not be closed after tap (default: true).'
}
]
},
Expand Down
17 changes: 11 additions & 6 deletions src/menus/icon-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let IconMenu = React.createClass({
onTouchTap: React.PropTypes.func,
menuStyle: React.PropTypes.object,
touchTapCloseDelay: React.PropTypes.number,
closeOnItemTouchTap: React.PropTypes.bool,
},

getDefaultProps() {
Expand All @@ -46,6 +47,7 @@ let IconMenu = React.createClass({
onMouseUp: () => {},
onTouchTap: () => {},
touchTapCloseDelay: 200,
closeOnItemTouchTap: true,
};
},

Expand Down Expand Up @@ -160,14 +162,17 @@ let IconMenu = React.createClass({
},

_handleItemTouchTap(e, child) {
let isKeyboard = Events.isKeyboard(e);

this._timeout = setTimeout(() => {
this.close(isKeyboard);
}, this.props.touchTapCloseDelay);
if (this.props.closeOnItemTouchTap) {
let isKeyboard = Events.isKeyboard(e);

if (isKeyboard) {
this.refs[this.state.iconButtonRef].setKeyboardFocus();
this._timeout = setTimeout(() => {
this.close(isKeyboard);
}, this.props.touchTapCloseDelay);

if (isKeyboard) {
this.refs[this.state.iconButtonRef].setKeyboardFocus();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think all of the isKeyboard logic should be inside the the new if block.


this.props.onItemTouchTap(e, child);
Expand Down