-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass child window as an argument to the onUnload callback? #6
Comments
I think you've uncovered a bug. There's an event handler that fires when the popup window is being unloaded and // Clean up
return () => {
// Fire props.onUnload()
if (onUnload) {
onUnload();
} I'm working on a fix. Will release a new version as soon as I change and test. Probably in a couple of days. Thanks for using react-new-improved-window |
The strange thing is, I saw it called twice in Chrome, but only once in Firefox. That makes me wonder if the beforeUnload window event is being fired correctly in Firefox. |
I'll be sure to test on multiple browsers. It will be a shame if FF behavior doesn't fire the What if a new FF version fixes this then I need to add a version check as well. What a mess. |
@anmcn I tried a bunch of changes and each time the popup window closes the main window with it. 😠 |
I have observed onUnload being called multiple times. I suspect, but have not been able to confirm, this happens when the pop-up window follows a redirect (attempts to debug with chrome devtools result in the behaviour changing).
In our application, we need to trigger certain actions when the popup closes, and this multiple triggering is causing those actions to be run prematurely. Ideally, onUnload would only be called when the pop-up actually closes, but this may be hard to achieve. If the child window was passed to the onLoad callback, one work-around would be to look at the child window.location.href, and only trigger those actions when the child window has reached it's final state.
The text was updated successfully, but these errors were encountered: