mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-13 20:31:48 +00:00
TextInput submit onKeyDown
This commit is contained in:
parent
7e83f9b071
commit
d9f5bec1f5
1 changed files with 5 additions and 5 deletions
|
|
@ -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 (
|
||||
<input
|
||||
size={1}
|
||||
|
|
@ -23,7 +23,7 @@ const TextInput = React.forwardRef((props, ref) => {
|
|||
{...props}
|
||||
ref={ref}
|
||||
className={classnames(props.className, styles['text-input'], { 'disabled': props.disabled })}
|
||||
onKeyUp={onKeyUp}
|
||||
onKeyDown={onKeyDown}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue