Please consider answer the question at spectrum channel.
Describe the question?
I have a textarea in the form and I want to trigger the form onSubmit when user press Enter
<textarea
name={variable}
ref={register}
onKeyPress={handleUserKeyPress}
rows="4"
defaultValue={submittedValue}
/>
and here is the handleUserKeyPress function
const handleUserKeyPress = e => {
if (e.key === "Enter" && !e.shiftKey) {
// e.preventDefault();
handleSubmit(onSubmit); // this won't be triggered
}
};
handleSubmit(onSubmit)();
Most helpful comment
handleSubmit(onSubmit)();