Set a default value for MessageInput component
Is it possible to define a default value for MessageInputSmall or MessageInputLarge. I'd like a user to open the chat and have the message box already filled in with a default message, then they would just hit send.
Is there a way to have that?
I couldn't find in the docs a way to do it other than using ChatAutoComplete component but then I'd lose out of the box features like attachments.
gz#6835
Agent comment from Anders Lund in Zendesk ticket #6835:
Sorry, Unfortunately this is not currently possible out-of-the-box. To achieve this You'll need to either use ChatAutoComplete or customize the MessageInput component
Nelio, here's a quick example of a simple way I customized the MessageInput in a recent app using ChatAutoComplete and re-adding ImageDropzone and UploadsPreview
return (
<div className="str-chat__messaging-input">
<div
className="messaging-input__button"
role="button"
aria-roledescription="button"
onClick={messageInput.openEmojiPicker}
ref={messageInput.emojiPickerRef}
>
<EmojiIcon />
</div>
<div
className="messaging-input__button"
role="button"
aria-roledescription="button"
onClick={onClickCommand}
>
<CommandIcon />
</div>
<ImageDropzone
accept={acceptedFiles}
handleFiles={messageInput.uploadNewFiles}
multiple={multipleUploads}
disabled={
(maxNumberOfFiles !== undefined &&
messageInput.numberOfUploads >= maxNumberOfFiles) ||
giphyState
}
>
<div className="messaging-input__input-wrapper">
{giphyState && !messageInput.numberOfUploads && <GiphyIcon />}
<UploadsPreview {...messageInput} />
<ChatAutoComplete
commands={messageInput.getCommands()}
innerRef={messageInput.textareaRef}
handleSubmit={messageInput.handleSubmit}
onSelectItem={messageInput.onSelectItem}
onChange={onChange}
value={messageInput.text}
rows={1}
maxRows={props.maxRows}
placeholder="Send a message"
onPaste={messageInput.onPaste}
triggers={props.autocompleteTriggers}
grow={props.grow}
disabled={props.disabled}
additionalTextareaProps={props.additionalTextareaProps}
/>
</div>
</ImageDropzone>
<div
className="messaging-input__button"
role="button"
aria-roledescription="button"
onClick={messageInput.handleSubmit}
>
<SendIcon />
</div>
<EmojiPicker {...messageInput} />
</div>
);