Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: use refs for comment submit/cancel shortcuts in TipTap handler

Tina592d0a6b88e
diff --git a/apps/web/src/components/activity/comment-editor.tsx b/apps/web/src/components/activity/comment-editor.tsx
index c9dfa204f..d02813eff 100644
--- a/apps/web/src/components/activity/comment-editor.tsx
+++ b/apps/web/src/components/activity/comment-editor.tsx
@@ -187,6 +187,10 @@ export default function CommentEditor({
const taskIdRef = useRef(taskId);
const ensureTaskIdRef = useRef(ensureTaskId);
const uploadSurfaceRef = useRef(uploadSurface);
+ const onSubmitShortcutRef = useRef(onSubmitShortcut);
+ const onCancelShortcutRef = useRef(onCancelShortcut);
+ onSubmitShortcutRef.current = onSubmitShortcut;
+ onCancelShortcutRef.current = onCancelShortcut;
const pendingImageInsertRef = useRef<{
editor: Editor;
range?: SlashRange;
@@ -809,9 +813,10 @@ export default function CommentEditor({
}
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
- if (!readOnly && !disabled && onSubmitShortcut) {
+ const submit = onSubmitShortcutRef.current;
+ if (!readOnly && !disabled && submit) {
event.preventDefault();
- onSubmitShortcut();
+ submit();
return true;
}
}
@@ -820,10 +825,10 @@ export default function CommentEditor({
event.key === "Escape" &&
!readOnly &&
!disabled &&
- onCancelShortcut
+ onCancelShortcutRef.current
) {
event.preventDefault();
- onCancelShortcut();
+ onCancelShortcutRef.current();
return true;
}