It was possible on web to create a new sidebar or thread with an empty (or including only
whitespaces) message. It is no longer so.
Linear issue:
https://linear.app/comm/issue/ENG-1437/sending-empty-message-on-web-is-possible-for-pending-chat-and-creates
Details
Check that it is no longer possible to create a new sidebar/thread with an empty/including only whitespaces message, but is
possible with a non-empty text message or a multimedia message.
Additionally check that sending text and multimedia messages is possible, including those where
the multimedia is chosen from a finder, pasted from a clipboard and drag-and-dropped.
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I think the title of the diff should reference any chat - not only sidebar.
The solution prevents creating a thread when trying to send an empty text message, but introduces another issues. Now it's impossible to send multimedia message without any text (because this.multimediaInput?.value.trim() is always '', even if we have multimedia message - but only if we drag-and-drop or paste message - if we select one using Finder, it works correctly), and pressing enter in empty text input bar creates newline what is probably not desired behavior (as every other pressing "enter" send new message)
What is interesting here, we already trim the message (https://github.com/CommE2E/comm/blob/e2d045ebf313b21a90a0efa4b6948b9b815b3fce/web/chat/chat-input-bar.react.js#L352), and prevent sending it if it contains only whitespaces or is empty.
The source of the problem may be in createMultimediaMessage (https://github.com/CommE2E/comm/blob/e2d045ebf313b21a90a0efa4b6948b9b815b3fce/web/input/input-state-container.react.js#L1016-L1051) which is executed every time, even when the message is empty - probably it may be creating new thread.
Maybe we should just check if multimedia input exists when before executing createMultimediaMessage to prevent thread creation?
It's worth to notice, that all web app input is kept in inputState object, so all actions on input should not be performed directly on input elements (this.textarea?.value), but on InputState (this.props.inputState.draft)