From da6252eb1a33951a65ea0551bedd346a4eba0ce5 Mon Sep 17 00:00:00 2001 From: Nathaniel Rindlaub Date: Sun, 3 Nov 2024 21:08:36 -1000 Subject: [PATCH] Fix scroll ref issue when deleting all comments, #253 --- src/features/loupe/CommentsPopover.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/features/loupe/CommentsPopover.jsx b/src/features/loupe/CommentsPopover.jsx index ee8a8cdf..b80e0c56 100644 --- a/src/features/loupe/CommentsPopover.jsx +++ b/src/features/loupe/CommentsPopover.jsx @@ -114,24 +114,24 @@ export const CommentsPopover = ({ onClose, comments, imageId, onChangeActionMenu const [isShiftDown, setIsShiftDown] = useState(false); const handleKeyDown = (event) => { event.stopPropagation(); - if (event.key === "Shift") { + if (event.key === 'Shift') { setIsShiftDown(true); } - if (event.key === "Enter" && !isShiftDown) { + if (event.key === 'Enter' && !isShiftDown) { handleAddComment(addCommentText); event.preventDefault(); } - } + }; const handleKeyUp = (event) => { - if (event.key === "Shift") { + if (event.key === 'Shift') { setIsShiftDown(false); } - } + }; // Scroll to bottom when adding a new comment const scrollRef = useRef(); useEffect(() => { - if (scrollRef.current !== undefined) { - scrollRef.current.scrollIntoView({ behavior: "smooth" }); + if (scrollRef.current) { + scrollRef.current.scrollIntoView({ behavior: 'smooth' }); } }, [comments]);