From 490eabf977239e6728ab3f6982fbfef3f5676b8e Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 13 Jul 2022 09:08:32 -0600 Subject: [PATCH] Revert "Revert "Disable enter to submit on mobile group chat"" This reverts commit e3f7f0efdad7320117ebd109b2c2630e2b7fecc8. --- web/components/feed/feed-comments.tsx | 14 +++++++++----- web/components/groups/group-chat.tsx | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/web/components/feed/feed-comments.tsx b/web/components/feed/feed-comments.tsx index c327d8af..198e9c36 100644 --- a/web/components/feed/feed-comments.tsx +++ b/web/components/feed/feed-comments.tsx @@ -31,6 +31,7 @@ import { track } from 'web/lib/service/analytics' import { useEvent } from 'web/hooks/use-event' import { Tipper } from '../tipper' import { CommentTipMap, CommentTips } from 'web/hooks/use-tip-txns' +import useMediaQuery from 'react-query/types/devtools/useMediaQuery' export function FeedCommentThread(props: { contract: Contract @@ -472,7 +473,7 @@ export function CommentInputTextArea(props: { isSubmitting: boolean setRef?: (ref: HTMLTextAreaElement) => void presetId?: string - enterToSubmit?: boolean + enterToSubmitOnDesktop?: boolean }) { const { isReply, @@ -484,9 +485,9 @@ export function CommentInputTextArea(props: { presetId, isSubmitting, replyToUsername, - enterToSubmit, + enterToSubmitOnDesktop, } = props - + const isMobile = innerWidth < 768 const memoizedSetComment = useEvent(setComment) useEffect(() => { if (!replyToUsername || !user || replyToUsername === user.username) return @@ -507,7 +508,7 @@ export function CommentInputTextArea(props: { placeholder={ isReply ? 'Write a reply... ' - : enterToSubmit + : enterToSubmitOnDesktop ? 'Send a message' : 'Write a comment...' } @@ -516,7 +517,10 @@ export function CommentInputTextArea(props: { disabled={isSubmitting} onKeyDown={(e) => { if ( - (enterToSubmit && e.key === 'Enter' && !e.shiftKey) || + (enterToSubmitOnDesktop && + e.key === 'Enter' && + !e.shiftKey && + !isMobile) || (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) ) { e.preventDefault() diff --git a/web/components/groups/group-chat.tsx b/web/components/groups/group-chat.tsx index c98f1af1..2cf2d73d 100644 --- a/web/components/groups/group-chat.tsx +++ b/web/components/groups/group-chat.tsx @@ -165,7 +165,7 @@ export function GroupChat(props: { replyToUsername={replyToUsername} submitComment={submitMessage} isSubmitting={isSubmitting} - enterToSubmit={true} + enterToSubmitOnDesktop={true} setRef={setInputRef} />