1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

added meta to comment form

This commit is contained in:
Fedor Katurov 2022-01-09 20:52:17 +07:00
parent 8f0ed34790
commit e99dc7d2c9

View file

@ -1,4 +1,9 @@
import React, { forwardRef, KeyboardEventHandler, TextareaHTMLAttributes, useCallback } from 'react'; import React, {
forwardRef,
KeyboardEventHandler,
TextareaHTMLAttributes,
useCallback,
} from 'react';
import { Textarea } from '~/components/input/Textarea'; import { Textarea } from '~/components/input/Textarea';
import { useCommentFormContext } from '~/hooks/comments/useCommentFormFormik'; import { useCommentFormContext } from '~/hooks/comments/useCommentFormFormik';
import { useRandomPhrase } from '~/constants/phrases'; import { useRandomPhrase } from '~/constants/phrases';
@ -11,8 +16,8 @@ const LocalCommentFormTextarea = forwardRef<HTMLTextAreaElement, IProps>(({ ...r
const { values, handleChange, handleSubmit, isSubmitting } = useCommentFormContext(); const { values, handleChange, handleSubmit, isSubmitting } = useCommentFormContext();
const onKeyDown = useCallback<KeyboardEventHandler<HTMLTextAreaElement>>( const onKeyDown = useCallback<KeyboardEventHandler<HTMLTextAreaElement>>(
({ ctrlKey, key }) => { ({ ctrlKey, key, metaKey }) => {
if (ctrlKey && key === 'Enter') handleSubmit(undefined); if ((ctrlKey || metaKey) && key === 'Enter') handleSubmit(undefined);
}, },
[handleSubmit] [handleSubmit]
); );