Skip to content

Commit

Permalink
[chore] improve documentation for shouldCloseOnOverlayClick.
Browse files Browse the repository at this point in the history
closes reactjs#620.
  • Loading branch information
diasbruno committed Feb 23, 2018
1 parent 9012d81 commit d8051f9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/examples/should_close_on_overlay_click.md
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)

0 comments on commit d8051f9

Please sign in to comment.