Skip to content

Commit

Permalink
[New #92] Added support of Esc key in comment dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Feb 2, 2022
1 parent d22e5cb commit 04959f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/comment/CommentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CommentForm = (props) => {
className="comment-form-control"
name="comment"
as="textarea"
placeholder="Write your comments here (Ctrl+Enter to confirm)"
placeholder="Write your comments here (Ctrl+Enter to confirm, Esc to cancel)"
required
value={commentValue}
onChange={onValueChange}
Expand Down
8 changes: 7 additions & 1 deletion src/components/comment/QuestionCommentIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const QuestionCommentIcon = (props) => {
} else setOverlayPlacement('right');
};

const onKeyDownHandler = (e) => {
if (e.key === 'Escape') {
hideOverlay();
}
};

return (
<div ref={overlayTarget} onClick={stopPropagation}>
<span ref={target} onClick={onClickSetShowHandler}>
Expand All @@ -96,7 +102,7 @@ const QuestionCommentIcon = (props) => {
<Overlay target={target.current} show={show} placement={overlayPlacement} rootClose={false} onHide={hideOverlay} container={dragRef}>
{(overlayProps) => (
<Tooltip className="comment-tooltip" {...overlayProps}>
<span>
<span onKeyDown={(e) => {onKeyDownHandler(e)}}>
<motion.div
className="close-comment-icon"
onClick={hideOverlay}
Expand Down

0 comments on commit 04959f6

Please sign in to comment.