-
Notifications
You must be signed in to change notification settings - Fork 393
Cancelling a comment doesn't work #1444
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
Cancelling a comment doesn't work #1444
Conversation
doCreate() | ||
}), | ||
button(['cancel'], {}, ['Cancel']).mousedown(() => controls.classList.add("hide")) | ||
button(['cancel'], {}, ['Cancel']).mousedown(() => {hide ? hide() : controls.classList.add("hide")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the NewComment 'cancel' button is pressed, if a 'hide' function is passed in, it is called to remove the whole component. Otherwise, the controls (the 'cancel' and 'submit' buttons) will be hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! If we wanted, we could maybe also clear the text in the comment text area specifically for replies (the 2nd branch of that ternary statement), so it both hides the controls and leaves a blank text box. Just an offhand thought, feel free to take or leave it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.clicked = true; | ||
|
||
const newComment = new NewComment(commentsState, () => range) | ||
const newComment = new NewComment(commentsState, () => range, this.hide.bind(this)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove a NewComment previously, a user had to click outside of the selected area of the cell. On line 131, this click called the 'CommentButton' hide function on line 397.
I chose to call this same hide function when a user presses 'cancel' on a root NewComment.
doCreate() | ||
}), | ||
button(['cancel'], {}, ['Cancel']).mousedown(() => controls.classList.add("hide")) | ||
button(['cancel'], {}, ['Cancel']).mousedown(() => {hide ? hide() : controls.classList.add("hide")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! If we wanted, we could maybe also clear the text in the comment text area specifically for replies (the 2nd branch of that ternary statement), so it both hides the controls and leaves a blank text box. Just an offhand thought, feel free to take or leave it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix!
This is a PR for the issue: #1435
Issue Description: "When writing a new root comment or replying to an existing one, hitting the 'cancel' button unfocuses the text box but doesn't actually delete the in-progress comment and hide the text field."
Example of the Issue:
Desired Response:
Note: The functionality for pressing the 'cancel' button when replying to an existing comment remains unchanged. I chose to do this because if the new comment is hidden, the UI leaves it unclear how to leave a reply.