diff --git a/app/src/components/JogControls/index.js b/app/src/components/JogControls/index.js index 0ea27064906..63b48e6de07 100644 --- a/app/src/components/JogControls/index.js +++ b/app/src/components/JogControls/index.js @@ -83,18 +83,21 @@ export default class JogControls extends React.Component { const {step, onStepSelect} = this.props return ( - + {JOG_BUTTON_NAMES.map(name => ( , + /** optionally call event.preventDefault if keypress is handled */ + preventDefault?: ?boolean, /** wrapped children */ children?: React.Node, } @@ -24,7 +26,8 @@ const matchHandler = e => h => ( /** * Keypress handler wrapper component. Takes an array of keypress handlers * to call when a given key is pressed on the keyboard. Handler is called on - * `keyup` event. `event.preventDefault` will be called if a key is handled. + * `keyup` event. `event.preventDefault` will be called if a key is handled + * and `props.preventDefault` is true. */ export default class HandleKeypress extends React.Component { handlePressIfKey = (event: KeypressEvent) => { @@ -34,6 +37,8 @@ export default class HandleKeypress extends React.Component { } preventDefaultIfKey = (event: KeypressEvent) => { + if (!this.props.preventDefault) return + const pressHandled = this.props.handlers.some(matchHandler(event)) if (pressHandled) event.preventDefault()