Skip to content
Merged
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
32 changes: 22 additions & 10 deletions src/menu/src/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,30 @@ class MenuItem extends React.PureComponent {
is: 'div',
intent: 'none',
appearance: 'default',
onClick: () => {},
onSelect: () => {},
onKeyPress: () => {}
onSelect: () => {}
}

handleClick = () => {
this.props.onSelect()
handleClick = event => {
this.props.onSelect(event)

/* eslint-disable react/prop-types */
if (typeof this.props.onClick === 'function') {
this.props.onClick(event)
}
/* eslint-enable react/prop-types */
}

handleKeyPress = e => {
if (e.key === 'Enter' || e.key === ' ') {
this.props.onSelect()
e.preventDefault()
handleKeyPress = event => {
if (event.key === 'Enter' || event.key === ' ') {
this.props.onSelect(event)
event.preventDefault()
}

/* eslint-disable react/prop-types */
if (typeof this.props.onKeyPress === 'function') {
this.props.onKeyPress(event)
}
/* eslint-enable react/prop-types */
}

render() {
Expand All @@ -78,7 +88,8 @@ class MenuItem extends React.PureComponent {
appearance,
secondaryText,
intent,
icon
icon,
...passthroughProps
} = this.props

const themedClassName = theme.getMenuItemClassName(appearance, 'none')
Expand All @@ -95,6 +106,7 @@ class MenuItem extends React.PureComponent {
data-isselecteable="true"
display="flex"
alignItems="center"
{...passthroughProps}
>
{icon && (
<Icon
Expand Down