Blur input on Enter key press

pull/10616/head
Jared Scheib 2017-08-07 17:22:59 -07:00
parent 5c0c457645
commit 9503074603
1 changed files with 10 additions and 0 deletions

View File

@ -30,6 +30,7 @@ class OneOrAny extends Component {
this.handleClickToggle = ::this.handleClickToggle
this.handleBlurRightValueInput = ::this.handleBlurRightValueInput
this.handleChangeRightValue = ::this.handleChangeRightValue
this.handleKeyPressRightValueInput = ::this.handleKeyPressRightValueInput
this.setRightValue = ::this.setRightValue
this.setValue = ::this.setValue
}
@ -98,6 +99,14 @@ class OneOrAny extends Component {
}
}
handleKeyPressRightValueInput() {
return e => {
if (e.key === 'Enter') {
this.rightValueInput.blur()
}
}
}
setRightValue(value) {
this.setState({rightValue: value}, this.setValue)
}
@ -152,6 +161,7 @@ class OneOrAny extends Component {
}}
onBlur={this.handleBlurRightValueInput()}
onChange={this.handleChangeRightValue()}
onKeyPress={this.handleKeyPressRightValueInput()}
placeholder={rightLabel}
disabled={!useRightValue}
/>