forked from reactjs/react-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] improve documentation for shouldCloseOnOverlayClick.
closes reactjs#620.
- Loading branch information
Showing
1 changed file
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# Using shouldCloseOnOverlayClick | ||
|
||
This example shows using `shouldCloseOnOverlayClick` set to `false` so that closing by clicking on the overlay doesn't work. | ||
When `shouldCloseOnOverlayClick` is `true` (default value for this property), | ||
it requires the `onRequestClose` to be defined in order to close the <Modal/>. | ||
This is due to the fact that the `react-modal` doesn't store the `isOpen` | ||
on its state (only for the internal `portal` (see [ModalPortal.js](https://github.com/reactjs/react-modal/blob/master/src/components/ModalPortal.js)). | ||
|
||
`shouldCloseOnOverlayClick` requires `onRequestClose` in order to close the <Modal/> because `react-modal` does not store `isOpen` in its local state. | ||
|
||
[](codepen://claydiffrient/woLzwo) | ||
[disable 'close on overlay click', codepen by claydiffrient](codepen://claydiffrient/woLzwo) | ||
[enable 'close on overlay click', codepen by sbgriffi](codepen://sbgriffi/WMyBaR) |