question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

closeOnBackdropClick works on backdrop to the left and right of image, but not above and below image

See original GitHub issue

Not sure if #313 would fix this—I’m not able to look closely at it right now.

Steps to reproduce the behavior:

Tested on Chrome with npm versions 1.1.0-beta.3, 1.1.0-beta.2, and 1.0.0. Also tested 1.1.0-beta.3 on Firefox and Safari. Here’s my JSX:

{/* Lightbox gallery */}
<ModalGateway>
  {lightboxOpen && (
    <Modal
      onClose={toggleLightbox}
      allowFullscreen={false}
      closeOnBackdropClick={true}
    >
      <Carousel
        currentIndex={lightboxIndex}
        views={photoSources}
      />
    </Modal>
  )}
</ModalGateway>

My state and toggle function:

// Lightbox gallery
const [lightboxIndex, setLightboxIndex] = useState(0);
const [lightboxOpen, setLightboxOpen] = useState(false);
const toggleLightbox = index => {
  setLightboxIndex(index);
  setLightboxOpen(!lightboxOpen);
};

Expected behavior:

Clicks on the backdrop on all sides of the image ought to close the modal.

Actual behavior:

Only backdrop clicks to the right and left of the image close the modal, not backdrop clicks above and below the image.

react-images-backdrop-click-bug

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:14

github_iconTop GitHub Comments

4reactions
lsnryszardbcommented, Feb 25, 2020

This worked for me as a temporary fix:

.react-images__view {
    display: flex;
    height: 100vh;
    align-items: center;
    justify-content: center;
}
1reaction
durdeviccommented, May 2, 2020

Okay, so following the “Can you check if this is still present in 1.1.4?” comment I updated to 1.1.4, and it was breaking, but now I saw that the latest version is 1.1.6. There it works perfectly! 😁

Awesome job mate! Super quick fixing 💪

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Close react native modal by clicking on overlay?
I use TouchableWithoutFeedback since i do not want to change the background color when clicking on it. I also added onStartShouldSetResponder on the...
Read more >
Modal - Bootstrap
Static backdrop. When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try...
Read more >
Modal | Components - BootstrapVue
Modals are streamlined, but flexible dialog prompts powered by JavaScript and ... close on backdrop click (enabled by default), and the X close...
Read more >
backdrop - CSS-Tricks
The ::backdrop CSS pseudo-element creates a backdrop that covers the entire viewport and is rendered immediately below a or any element ...
Read more >
Dialog Angular UI Component - Nebular - GitHub Pages
If you are using it in a lazy loaded module than you have to install it with ... closeOnBackdropClick - close dialog on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found