Skip to content

Commit

Permalink
Merge pull request #254 from tnc-ca-geo/fix/253-comments_popover
Browse files Browse the repository at this point in the history
Fix scroll ref issue when deleting all comments, #253
  • Loading branch information
nathanielrindlaub authored Nov 4, 2024
2 parents cc7895a + da6252e commit 56d9f8f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/features/loupe/CommentsPopover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 56d9f8f

Please sign in to comment.