Raccourci clavier 'Entrer' pour valider les questions à choix aussi
parent
e7f2f658ce
commit
64fd6b84bf
|
@ -40,9 +40,6 @@ export default class Input extends Component {
|
|||
? { border: '2px dashed #ddd' }
|
||||
: { border: `1px solid ${themeColours.textColourOnWhite}` }
|
||||
}
|
||||
onKeyDown={({ key }) =>
|
||||
key == 'Enter' && (submitDisabled ? input.onBlur() : submit())
|
||||
}
|
||||
/>
|
||||
{suffixed && (
|
||||
<label
|
||||
|
|
|
@ -7,6 +7,19 @@ export default class SendButton extends Component {
|
|||
let { disabled, submit } = this.props
|
||||
return () => (!disabled ? submit() : null)
|
||||
}
|
||||
componentDidMount() {
|
||||
// removeEventListener will need the exact same function instance
|
||||
this.boundHandleKeyDown = this.handleKeyDown.bind(this)
|
||||
|
||||
window.addEventListener('keydown', this.boundHandleKeyDown)
|
||||
}
|
||||
componentWillUnmount() {
|
||||
window.removeEventListener('keydown', this.boundHandleKeyDown)
|
||||
}
|
||||
handleKeyDown({ key }) {
|
||||
if (key !== 'Enter') return
|
||||
this.getAction()()
|
||||
}
|
||||
render() {
|
||||
let { disabled, themeColours, hover } = this.props
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue