From 4c801f76b4b4d03765b140af49a0d292c5243c6b Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 9 Sep 2022 11:09:31 -0700 Subject: [PATCH] Submit comments on ctrl/cmd-enter (#830) * Submit comments on ctrl/cmd-enter * Remove unused import * Tweak padding on /tournaments * Always submit on ctrl+enter Since we took out group chats, this should be fine for all comments --- web/components/comment-input.tsx | 10 ++-------- web/components/feed/feed-comments.tsx | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/web/components/comment-input.tsx b/web/components/comment-input.tsx index 1d0b3cc1..ca1f4a96 100644 --- a/web/components/comment-input.tsx +++ b/web/components/comment-input.tsx @@ -4,7 +4,6 @@ import clsx from 'clsx' import { User } from 'common/user' import { useEffect, useState } from 'react' import { useUser } from 'web/hooks/use-user' -import { useWindowSize } from 'web/hooks/use-window-size' import { MAX_COMMENT_LENGTH } from 'web/lib/firebase/comments' import { Avatar } from './avatar' import { TextEditor, useTextEditor } from './editor' @@ -80,7 +79,6 @@ export function CommentInputTextArea(props: { upload: Parameters[0]['upload'] submitComment: (id?: string) => void isSubmitting: boolean - submitOnEnter?: boolean presetId?: string }) { const { @@ -90,11 +88,8 @@ export function CommentInputTextArea(props: { submitComment, presetId, isSubmitting, - submitOnEnter, replyToUser, } = props - const isMobile = (useWindowSize().width ?? 0) < 768 // TODO: base off input device (keybord vs touch) - useEffect(() => { editor?.setEditable(!isSubmitting) }, [isSubmitting, editor]) @@ -108,15 +103,14 @@ export function CommentInputTextArea(props: { if (!editor) { return } - // submit on Enter key + // Submit on ctrl+enter or mod+enter key editor.setOptions({ editorProps: { handleKeyDown: (view, event) => { if ( - submitOnEnter && event.key === 'Enter' && !event.shiftKey && - (!isMobile || event.ctrlKey || event.metaKey) && + (event.ctrlKey || event.metaKey) && // mention list is closed !(view.state as any).mention$.active ) { diff --git a/web/components/feed/feed-comments.tsx b/web/components/feed/feed-comments.tsx index a63a4b6e..a3e9f35a 100644 --- a/web/components/feed/feed-comments.tsx +++ b/web/components/feed/feed-comments.tsx @@ -20,7 +20,6 @@ import { getProbability } from 'common/calculate' import { track } from 'web/lib/service/analytics' import { Tipper } from '../tipper' import { CommentTipMap, CommentTips } from 'web/hooks/use-tip-txns' - import { Content } from '../editor' import { Editor } from '@tiptap/react' import { UserLink } from 'web/components/user-link'