fix:opening wrong and downloading wrong image

This commit is contained in:
Damien Ostler 2024-05-26 16:38:35 -04:00
parent a3382a6434
commit d8e30415cb

View File

@ -124,13 +124,15 @@ const Gallery = ({ id, closeMenu }: GalleryProps) => {
} }
}; };
setSelectedImage(images[currentIndex]);
window.addEventListener('keydown', handleKeyDown); window.addEventListener('keydown', handleKeyDown);
// Clean up the event listener when the component is unmounted // Clean up the event listener when the component is unmounted
return () => { return () => {
window.removeEventListener('keydown', handleKeyDown); window.removeEventListener('keydown', handleKeyDown);
}; };
}, [selectedImage, currentIndex]);
}, [currentIndex]);
const handleClick = (image: string) => { const handleClick = (image: string) => {
setSelectedImage(image); setSelectedImage(image);