I am building a typical chat interface:
- a div with list of messages
- a form at the bottom;
When the form is submitted, the new message is stored in db and appended through turbo stream into the list of messages. Also the submitted form is replaced with identical form w/o the message (i.e. with empty input field). The problem is that I can’t seem to find an appropriate turbo event that would allow me to focus()
the message body input field.
I am wondering if my approach is too complex and I just should use turbo:submit-end
or turbo:before-fetch-response
and just clear the value of the input field without rerendering the message form?