Remove empty comment and mark on cancel
This commit is contained in:
@@ -69,7 +69,7 @@ function CommentForm({
|
|||||||
const { comments } = useStores();
|
const { comments } = useStores();
|
||||||
const user = useCurrentUser();
|
const user = useCurrentUser();
|
||||||
|
|
||||||
useOnClickOutside(formRef, () => {
|
const reset = React.useCallback(() => {
|
||||||
const isEmpty = editorRef.current?.isEmpty() ?? true;
|
const isEmpty = editorRef.current?.isEmpty() ?? true;
|
||||||
|
|
||||||
if (isEmpty && thread?.isNew) {
|
if (isEmpty && thread?.isNew) {
|
||||||
@@ -78,7 +78,9 @@ function CommentForm({
|
|||||||
}
|
}
|
||||||
thread.delete();
|
thread.delete();
|
||||||
}
|
}
|
||||||
});
|
}, [editor, thread]);
|
||||||
|
|
||||||
|
useOnClickOutside(formRef, reset);
|
||||||
|
|
||||||
const handleCreateComment = action(async (event: React.FormEvent) => {
|
const handleCreateComment = action(async (event: React.FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -175,6 +177,7 @@ function CommentForm({
|
|||||||
setData(undefined);
|
setData(undefined);
|
||||||
setForceRender((s) => ++s);
|
setForceRender((s) => ++s);
|
||||||
setInputFocused(false);
|
setInputFocused(false);
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFocus = () => {
|
const handleFocus = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user