You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clear the input field after a message has been successfully posted;
fix TS warning for this line: const text = form.get("message").valueOf(); - text can be null;
make input field required or disable send message button if no input entered;
Steps to reproduce
Go to a chat room.
Submit the empty string. You can see the party server received the empty text
Put any message in the input field. The message stays after submission.
Expected behavior
Users should not be able to submit an empty text.
Input field should be cleared after submission.
Screenshots
Possible Solution
Right now, we use the FormData to get the input value
const form = new FormData(event.target as HTMLFormElement);
const text = form.get("message").valueOf();
I think it's better to utilize useState for inputValue to reset the input field after submission.
I would add const [inputValue, setInputValue] = useState(""); to the line 15,
add value={inputValue} onChange={(e) => { setInputValue(e.target.value); }} to the input element at the line 52,
and modify form onSubmit like this
Thanks for the issue, our team will look into it as soon as possible! If you would like to work on this issue, please wait for us to decide if it's ready. The issue will be ready to work on once we remove the "needs triage" label.
To claim an issue that does not have the "needs triage" label, please leave a comment that says ".take".
For full info on how to contribute, please check out our contributors guide.
It's currently an uncontrolled input. I opted to not use component state. Once it runs socket.send, you can run form.reset() and it will clear the message.
Describe the bug
This bugs were mentioned by @Arol15
Steps to reproduce
Expected behavior
Screenshots
Possible Solution
Right now, we use the FormData to get the input value
I think it's better to utilize useState for inputValue to reset the input field after submission.
I would add
const [inputValue, setInputValue] = useState("");
to the line 15,add
value={inputValue} onChange={(e) => { setInputValue(e.target.value); }}
to the input element at the line 52,and modify form onSubmit like this
The text was updated successfully, but these errors were encountered: