/** @format */ /** * External dependencies */ import { Component } from '@wordpress/element'; import { ENTER, SPACE } from '@wordpress/keycodes'; import PropTypes from 'prop-types'; class MenuItem extends Component { constructor() { super( ...arguments ); this.onClick = this.onClick.bind( this ); this.onKeyDown = this.onKeyDown.bind( this ); } onClick( event ) { const { isClickable, onInvoke } = this.props; if ( isClickable ) { event.preventDefault(); onInvoke(); } } onKeyDown( event ) { if ( event.keyCode === ENTER || event.keyCode === SPACE ) { event.preventDefault(); this.props.onInvoke(); } } render() { const { children } = this.props; return (