akiran / react-foundation-apps

Foundation Apps components built with React
http://webrafter.com/opensource/react-foundation-apps
MIT License
292 stars 48 forks source link

The modal's overlay allows closing without an event #34

Open jcalfee opened 8 years ago

jcalfee commented 8 years ago

Their is no way to detect when a user clicks away from the model (on the background) triggering it to close. The event happens here when it calls this.setState({open: false}):

https://github.com/akiran/react-foundation-apps/blob/master/src/modal/index.jsx#L35

  hideOverlay: function (e) {
    e.preventDefault();
    if (this.props.overlayClose) {
      this.setState({open: false});   
    }
  },

In our case, we can't use componentWillUnmount, we are using a global model that remains mounted the entire life of the app. When subscribed to the model ZfApi.subscribe(this.props.modalId, (name, msg) => { it would be ideal to see a "close" event issued for the overlayClose in addition to the X and Cancel.