Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Cancel button functionality to child comment #9569

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type CommentEditorProps = {
editorValue: string;
shouldFocus: boolean;
tooltipText?: string;
isReplying?: boolean;
};

export const CommentEditor = ({
Expand All @@ -38,6 +39,7 @@ export const CommentEditor = ({
editorValue,
shouldFocus,
tooltipText,
isReplying,
}: CommentEditorProps) => {
return (
<div className="CommentEditor">
Expand Down Expand Up @@ -72,7 +74,7 @@ export const CommentEditor = ({
/>
<div className="form-bottom">
<div className="form-buttons">
{editorValue.length > 0 && (
{(editorValue.length > 0 || isReplying) && (
<CWButton buttonType="tertiary" onClick={onCancel} label="Cancel" />
)}
<CWButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type CreateCommentProps = {
rootThread: Thread;
canComment: boolean;
tooltipText?: string;
isReplying?: boolean;
};

export const CreateComment = ({
Expand All @@ -34,6 +35,7 @@ export const CreateComment = ({
rootThread,
canComment,
tooltipText = '',
isReplying,
}: CreateCommentProps) => {
const { saveDraft, restoreDraft, clearDraft } = useDraft<DeltaStatic>(
!parentCommentId
Expand Down Expand Up @@ -136,6 +138,7 @@ export const CreateComment = ({
const handleCancel = (e) => {
e.preventDefault();
setContentDelta(createDeltaFromText(''));

if (handleIsReplying) {
handleIsReplying(false);
}
Expand All @@ -161,6 +164,7 @@ export const CreateComment = ({
author={author as Account}
editorValue={editorValue}
tooltipText={tooltipText}
isReplying={isReplying}
/>
) : (
<ArchiveMsg archivedAt={rootThread.archivedAt} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export const CommentTree = ({
setIsGloballyEditing(false);
}
};

const handleEditStart = (comment: CommentType<any>) => {
const editDraft = localStorage.getItem(
`${app.activeChainId()}-edit-comment-${comment.id}-storedText`,
Expand Down Expand Up @@ -530,6 +529,7 @@ export const CommentTree = ({
parentCommentId={parentCommentId}
rootThread={thread}
canComment={canComment}
isReplying={isReplying}
/>
)}
</React.Fragment>
Expand Down
Loading