[WEB-1689] fix: command enter submits the form (#4986)

* fix: command enter submits the form

* fix: build errors
This commit is contained in:
Aaryan Khandelwal 2024-07-01 17:00:53 +05:30 committed by GitHub
parent 936c21d65e
commit e78263e01f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 46 additions and 41 deletions

View file

@ -64,7 +64,11 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp
}}
isSubmitting={isSubmitting}
showSubmitButton={showSubmitButton}
handleSubmit={(e) => rest.onEnterKeyPress?.(e)}
handleSubmit={() => {
if (isMutableRefObject<EditorRefApi>(ref)) {
rest.onEnterKeyPress?.(ref.current?.getHTML() ?? "");
}
}}
isCommentEmpty={isEmpty}
editorRef={isMutableRefObject<EditorRefApi>(ref) ? ref : null}
/>

View file

@ -12,7 +12,7 @@ import { cn } from "@/helpers/common.helper";
type Props = {
executeCommand: (commandName: EditorMenuItemNames) => void;
handleSubmit: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
handleSubmit: () => void;
isCommentEmpty: boolean;
isSubmitting: boolean;
showSubmitButton: boolean;
@ -95,7 +95,7 @@ export const IssueCommentToolbar: React.FC<Props> = (props) => {
{showSubmitButton && (
<div className="sticky right-1">
<Button
type="submit"
type="button"
variant="primary"
className="px-2.5 py-1.5 text-xs"
onClick={handleSubmit}

View file

@ -66,8 +66,8 @@ export const AddComment: React.FC<Props> = observer((props) => {
control={control}
render={({ field: { value, onChange } }) => (
<LiteTextEditor
onEnterKeyPress={(e) => {
if (currentUser) handleSubmit(onSubmit)(e);
onEnterKeyPress={() => {
if (currentUser) handleSubmit(onSubmit)();
}}
workspaceId={workspaceID?.toString() ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}

View file

@ -103,7 +103,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {
<LiteTextEditor
workspaceId={workspaceID?.toString() ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}
onEnterKeyPress={handleSubmit(handleCommentUpdate)}
onEnterKeyPress={() => handleSubmit(handleCommentUpdate)()}
ref={editorRef}
initialValue={value}
value={null}