minutemailer / react-popup

React popup component
http://minutemailer.github.io/react-popup/
MIT License
208 stars 71 forks source link

Provide the possibility to set the callback when popup is closed not by clicking on the footer buttons #48

Closed Salasar closed 6 years ago

Salasar commented 6 years ago

Currently it looks like there is no possibility to attach the callback when user closes popup by:

  1. clicking outside
  2. clicking on cross button (a.k.a. closeBtn)
  3. using Esc button on the keyboard.

Could you add such functionality? In my case I want to manage popup state via Redux so maybe adding of general handler for closing could help.

tbleckert commented 6 years ago

Hi! There's a global close listener that you use like this:

Popup.addCloseListener(() => {
    console.log('Popup closed');
});

In the master branch and upcoming v1.0.0 release you will also get the ID of the closed popup in the callback.

There's also a addOpenListener.

Now that you mention it, I don't think this is documented anywhere. Hope this is what you wanted, if so, feel free to close it, otherwise just let me know.

Salasar commented 6 years ago

@tbleckert thank you for the quick response, it's exactly what I was looking for. I hope, it will be added to the docs in the future :) Thanks!