Disable enter to submit on mobile group chat
This commit is contained in:
parent
9e90f849a8
commit
b3f4c2f009
|
@ -31,6 +31,7 @@ import { track } from 'web/lib/service/analytics'
|
||||||
import { useEvent } from 'web/hooks/use-event'
|
import { useEvent } from 'web/hooks/use-event'
|
||||||
import { Tipper } from '../tipper'
|
import { Tipper } from '../tipper'
|
||||||
import { CommentTipMap, CommentTips } from 'web/hooks/use-tip-txns'
|
import { CommentTipMap, CommentTips } from 'web/hooks/use-tip-txns'
|
||||||
|
import useMediaQuery from 'react-query/types/devtools/useMediaQuery'
|
||||||
|
|
||||||
export function FeedCommentThread(props: {
|
export function FeedCommentThread(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -472,7 +473,7 @@ export function CommentInputTextArea(props: {
|
||||||
isSubmitting: boolean
|
isSubmitting: boolean
|
||||||
setRef?: (ref: HTMLTextAreaElement) => void
|
setRef?: (ref: HTMLTextAreaElement) => void
|
||||||
presetId?: string
|
presetId?: string
|
||||||
enterToSubmit?: boolean
|
enterToSubmitOnDesktop?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
isReply,
|
isReply,
|
||||||
|
@ -484,9 +485,9 @@ export function CommentInputTextArea(props: {
|
||||||
presetId,
|
presetId,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
replyToUsername,
|
replyToUsername,
|
||||||
enterToSubmit,
|
enterToSubmitOnDesktop,
|
||||||
} = props
|
} = props
|
||||||
|
const isMobile = innerWidth < 768
|
||||||
const memoizedSetComment = useEvent(setComment)
|
const memoizedSetComment = useEvent(setComment)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!replyToUsername || !user || replyToUsername === user.username) return
|
if (!replyToUsername || !user || replyToUsername === user.username) return
|
||||||
|
@ -507,7 +508,7 @@ export function CommentInputTextArea(props: {
|
||||||
placeholder={
|
placeholder={
|
||||||
isReply
|
isReply
|
||||||
? 'Write a reply... '
|
? 'Write a reply... '
|
||||||
: enterToSubmit
|
: enterToSubmitOnDesktop
|
||||||
? 'Send a message'
|
? 'Send a message'
|
||||||
: 'Write a comment...'
|
: 'Write a comment...'
|
||||||
}
|
}
|
||||||
|
@ -516,7 +517,10 @@ export function CommentInputTextArea(props: {
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (
|
if (
|
||||||
(enterToSubmit && e.key === 'Enter' && !e.shiftKey) ||
|
(enterToSubmitOnDesktop &&
|
||||||
|
e.key === 'Enter' &&
|
||||||
|
!e.shiftKey &&
|
||||||
|
!isMobile) ||
|
||||||
(e.key === 'Enter' && (e.ctrlKey || e.metaKey))
|
(e.key === 'Enter' && (e.ctrlKey || e.metaKey))
|
||||||
) {
|
) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -165,7 +165,7 @@ export function GroupChat(props: {
|
||||||
replyToUsername={replyToUsername}
|
replyToUsername={replyToUsername}
|
||||||
submitComment={submitMessage}
|
submitComment={submitMessage}
|
||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
enterToSubmit={true}
|
enterToSubmitOnDesktop={true}
|
||||||
setRef={setInputRef}
|
setRef={setInputRef}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user