mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added meta to comment form
This commit is contained in:
parent
8f0ed34790
commit
e99dc7d2c9
1 changed files with 8 additions and 3 deletions
|
@ -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]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue