only submit on enter in chat

This commit is contained in:
Sinclair Chen 2022-08-03 16:20:48 -07:00
parent f9ee5031fd
commit 18152ff655
2 changed files with 4 additions and 0 deletions

View File

@ -447,6 +447,7 @@ export function CommentInputTextArea(props: {
upload: any upload: any
submitComment: (id?: string) => void submitComment: (id?: string) => void
isSubmitting: boolean isSubmitting: boolean
submitOnEnter?: boolean
presetId?: string presetId?: string
}) { }) {
const { const {
@ -456,6 +457,7 @@ export function CommentInputTextArea(props: {
submitComment, submitComment,
presetId, presetId,
isSubmitting, isSubmitting,
submitOnEnter,
replyToUser, replyToUser,
} = props } = props
const isMobile = (useWindowSize().width ?? 0) < 768 // TODO: base off input device (keybord vs touch) const isMobile = (useWindowSize().width ?? 0) < 768 // TODO: base off input device (keybord vs touch)
@ -478,6 +480,7 @@ export function CommentInputTextArea(props: {
editorProps: { editorProps: {
handleKeyDown: (view, event) => { handleKeyDown: (view, event) => {
if ( if (
submitOnEnter &&
event.key === 'Enter' && event.key === 'Enter' &&
!event.shiftKey && !event.shiftKey &&
(!isMobile || event.ctrlKey || event.metaKey) && (!isMobile || event.ctrlKey || event.metaKey) &&

View File

@ -162,6 +162,7 @@ export function GroupChat(props: {
replyToUser={replyToUser} replyToUser={replyToUser}
submitComment={submitMessage} submitComment={submitMessage}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
submitOnEnter
/> />
</div> </div>
</div> </div>