How to prevent click outside React Modal?
13,422
add this line to your modal component
<ReactModal
//other props declaration..
shouldCloseOnOverlayClick={false} // add this to prevent outside click to prevent modal close
>
or use event.preventDefault()
to fix it
Author by
Panayiotis Georgiou
React.js, GraphQL, Material UI and mobile apps. When I am not writing code π¨π»βπ» I enjoy photography π·, flying drones π and playing beach volleyball πor tennis πΎ
Updated on June 15, 2022Comments
-
Panayiotis Georgiou almost 2 years
I'm currently using react-modal package.
I want to disable click and scroll outside react modal component.
-
Chris over 6 yearsYou have to show what progress you've done so far. Show us your code and explain what you have tried.
-
-
Panayiotis Georgiou over 6 yearsthan will do it!
-
Dimitar Christoff over 6 yearsif it's a parent element this won't allow closing or interacting with modal either