shouldCloseOnOverlayClick should close on overlay click and shouldCloseOnEsc should close on esc!
https://reactcommunity.org/react-modal/examples/minimal/
Hi @nth-chile, yeah...the examples is very old. It's using [email protected], but it's weird that it's not working 馃.
Yeah I first noticed because I wanted to use these two flags in my app today, so it seems like an issue with current version
Have you used react-modal on the latest version?
It is ^3.12.1
Thanks. Can you make a reproducible example?
Let me know if this demonstrates the issue: https://codesandbox.io/s/dreamy-cannon-9r360?file=/src/App.js
react-modal used a callback function onRequestClose that is called in this cases.
Try to add to your code and let me know if it solves your problem.
onRequestClose is used to control the state of isOpen flag.
Here is one way to do it. https://codesandbox.io/s/priceless-bouman-f9hq9
...but we definitely need to update the docs. I'll flag this as documentation.
Ah ok, so the two flags I mentioned just fire onRequestClose
Edit: and they default to true, so there is no need to include them. I just needed to define onRequestClose. Maybe the docs say that & I missed it. Thanks for the help
Awesome, @nth-chile.
Most helpful comment
onRequestCloseis used to control the state ofisOpenflag.