<commit_before>// @flow
// jog controls component
import * as React from 'react'
import cx from 'classnames'

import type {JogAxis, JogDirection, JogStep} from '../../http-api-client'

import {
  PrimaryButton,
  RadioGroup,
  Icon,
  HandleKeypress,
  type IconName,
} from '@opentrons/components'

import styles from './styles.css'

export type Jog = (axis: JogAxis, direction: JogDirection, step: JogStep) => mixed

type JogButtonProps = {
  name: string,
  icon: IconName,
  onClick: () => mixed,
}

type Props = {jog: Jog}

type State = {step: JogStep}

const JOG_BUTTON_NAMES = ['left', 'right', 'back', 'forward', 'up', 'down']

const JOG_ICONS_BY_NAME = {
  left: 'ot-arrow-left',
  right: 'ot-arrow-right',
  back: 'ot-arrow-up',
  forward: 'ot-arrow-down',
  up: 'ot-arrow-up',
  down: 'ot-arrow-down',
}

const JOG_PARAMS_BY_NAME = {
  left: ['x', -1],
  right: ['x', 1],
  back: ['y', 1],
  forward: ['y', -1],
  up: ['z', 1],
  down: ['z', -1],
}

const STEPS: Array<JogStep> = [0.1, 1, 10]
const STEP_OPTIONS = STEPS.map(s => ({name: `${s} mm`, value: `${s}`}))

export default class JogControls extends React.Component<Props, State> {
  constructor (props: Props) {
    super(props)
    this.state = {step: STEPS[0]}
  }

  increaseStepSize = () => {
    const i = STEPS.indexOf(this.state.step)
    if (i < STEPS.length - 1) this.setState({step: STEPS[i + 1]})
  }

  decreaseStepSize = () => {
    const i = STEPS.indexOf(this.state.step)
    if (i > 0) this.setState({step: STEPS[i - 1]})
  }

  handleStepSelect = (event: SyntheticInputEvent<*>) => {
    this.setState({step: Number(event.target.value)})
  }

  getJogHandlers () {
    const {jog} = this.props
    const {step} = this.state
<commit_msg>fix(app): Prevent keypresses from changing jog jump size (#2315)<commit_after>// @flow
// jog controls component
import * as React from 'react'
import cx from 'classnames'

import type {JogAxis, JogDirection, JogStep} from '../../http-api-client'

import {
  PrimaryButton,
  RadioGroup,
  Icon,
  HandleKeypress,
  type IconName,
} from '@opentrons/components'

import styles from './styles.css'

export type Jog = (axis: JogAxis, direction: JogDirection, step: JogStep) => mixed

type JogButtonProps = {
  name: string,
  icon: IconName,
  onClick: () => mixed,
}

type Props = {jog: Jog}

type State = {step: JogStep}

const JOG_BUTTON_NAMES = ['left', 'right', 'back', 'forward', 'up', 'down']

const JOG_ICONS_BY_NAME = {
  left: 'ot-arrow-left',
  right: 'ot-arrow-right',
  back: 'ot-arrow-up',
  forward: 'ot-arrow-down',
  up: 'ot-arrow-up',
  down: 'ot-arrow-down',
}

const JOG_PARAMS_BY_NAME = {
  left: ['x', -1],
  right: ['x', 1],
  back: ['y', 1],
  forward: ['y', -1],
  up: ['z', 1],
  down: ['z', -1],
}

const STEPS: Array<JogStep> = [0.1, 1, 10]
const STEP_OPTIONS = STEPS.map(s => ({name: `${s} mm`, value: `${s}`}))

export default class JogControls extends React.Component<Props, State> {
  constructor (props: Props) {
    super(props)
    this.state = {step: STEPS[0]}
  }

  increaseStepSize = () => {
    const i = STEPS.indexOf(this.state.step)
    if (i < STEPS.length - 1) this.setState({step: STEPS[i + 1]})
  }

  decreaseStepSize = () => {
    const i = STEPS.indexOf(this.state.step)
    if (i > 0) this.setState({step: STEPS[i - 1]})
  }

  handleStepSelect = (event: SyntheticInputEvent<*>) => {
    this.setState({step: Number(event.target.value)})
    event.target.blur()
  }

  getJogHandlers () {
    const {jog} = this.props
    const {step} = this.state

{'fraction_non_alphanumeric': 0.1824381926683717, 'fraction_numerical': 0.010230179028132993, 'mean_word_length': 3.5833333333333335, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3418422', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1349, 'n_words': 335}