Skip to content

[BUG] Closing Lightbox of Zoomed Image with Click Away - Cannot read properties of undefined (reading 'x') #76

@CSFelix

Description

@CSFelix

Steps to Reproduce

  1. open an image modal with lightbox:
const [showLightbox, setShowLightbox] = useState(true);

const handleCloseLightbox = () => {
  setTimeout(() => {
    setShowLightbox(false);
    if (setIsLightboxVisible) setIsLightboxVisible(false);
  }, 50);
};

{showLightbox && (
  <Lightbox
    smallSrcSet={smallImgSrc}
    medium={mediumImgSrc}
    large={largeImgSrc}
    alt={'Caption'}

    showRotate={true}
    onClose={handleCloseLightbox}
  />
)}
  1. Click on zoom button

image

  1. Click on any dimmed area to close the modal keeping the image zoomed

image

  1. The error will be triggered

image

image


Expected Behavior

Lightbox should close without triggering errors, as it does when closed by pressing ESC or by clicking the close (x) button.


Version

  • react-modal-image: 2.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions