From d9f5bec1f510ceef593d52e7384d0d057bef37e5 Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Tue, 19 Nov 2019 11:36:54 +0200 Subject: [PATCH] TextInput submit onKeyDown --- src/common/TextInput/TextInput.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/TextInput/TextInput.js b/src/common/TextInput/TextInput.js index 88f263348..4f7db50f1 100644 --- a/src/common/TextInput/TextInput.js +++ b/src/common/TextInput/TextInput.js @@ -3,15 +3,15 @@ const classnames = require('classnames'); const styles = require('./styles'); const TextInput = React.forwardRef((props, ref) => { - const onKeyUp = React.useCallback((event) => { - if (typeof props.onKeyUp === 'function') { - props.onKeyUp(event); + const onKeyDown = React.useCallback((event) => { + if (typeof props.onKeyDown === 'function') { + props.onKeyDown(event); } if (event.key === 'Enter' && !event.nativeEvent.submitPrevented && typeof props.onSubmit === 'function') { props.onSubmit(event); } - }, [props.onKeyUp, props.onSubmit]); + }, [props.onKeyDown, props.onSubmit]); return ( { {...props} ref={ref} className={classnames(props.className, styles['text-input'], { 'disabled': props.disabled })} - onKeyUp={onKeyUp} + onKeyDown={onKeyDown} /> ); });