Fix form submit

This commit is contained in:
Anthony Laibe 2019-02-04 09:30:06 +01:00
parent 135bd9e14a
commit 972a898039
1 changed files with 3 additions and 2 deletions

View File

@ -60,7 +60,7 @@ const keyDownHandler = (e, typingEvent, setValue, value) => {
else if (e.keyCode === 13) { else if (e.keyCode === 13) {
e.preventDefault(); e.preventDefault();
const form = ChatRoomForm.current; const form = ChatRoomForm.current;
form.dispatchEvent(new Event("submit")); form.submitForm();
} }
typingEvent(e) typingEvent(e)
}; };
@ -152,6 +152,7 @@ class ChatRoom extends Component {
))} ))}
</AutoScrollList> </AutoScrollList>
<Formik <Formik
ref={ChatRoomForm}
initialValues={{ chatInput: '' }} initialValues={{ chatInput: '' }}
onSubmit={(values, { setSubmitting, resetForm }) => { onSubmit={(values, { setSubmitting, resetForm }) => {
const { chatInput } = values; const { chatInput } = values;
@ -170,7 +171,7 @@ class ChatRoom extends Component {
setFieldValue setFieldValue
}) => ( }) => (
<div className="chat-input"> <div className="chat-input">
<form onSubmit={handleSubmit} style={formStyle} ref={ChatRoomForm}> <form onSubmit={handleSubmit} style={formStyle}>
<Button onClick={(e) => this.uploadFileDialog()}><AddCircle /></Button> <Button onClick={(e) => this.uploadFileDialog()}><AddCircle /></Button>
<TextField <TextField
id="chatInput" id="chatInput"