pradel / react-responsive-modal

Simple responsive react modal
https://react-responsive-modal.leopradel.com/
MIT License
604 stars 95 forks source link

Modal does not work with dynamically set `closeOnEsc` prop #504

Open neefrehman opened 1 year ago

neefrehman commented 1 year ago

Bug report

Describe the bug

I'm working on a modal implementation where, if an error is encountered, the user can no longer exit the modal via clicking on the overlay or by pressing escape. They should instead follow the subsequent instructions shown in the modal. When doing this, I noticed that the closeOnEsc behaviour wasn't taking effect, whereas closeOnOverlayClick worked fine with the same prop value of !isError.

To Reproduce

A minimal repro sandbox can be found here

Expected behaviour

The modal should not be able to close when the closeOnEsc prop gets dynamically set to false due to a react state update.

System information