krakenjs / zoid

Cross domain components
Apache License 2.0
2.01k stars 248 forks source link

Add support to not destroy xcomponent when parent page navigates away #89

Closed mmairs9-zz closed 7 years ago

mmairs9-zz commented 7 years ago

Unfortunately we are seeing some lag in our Sharepoint environment where we have an xcomponent rendering. When navigating to a new page we receive a slow response from a server, can we not destroy the xcomponent immediately as it disappears off view before anything else on the page?

mmairs9-zz commented 7 years ago

I created a PR for this. You may want to change the prop name.

bluepnume commented 7 years ago

What do you think about keeping this non-configurable, but only applying it to popups?

The reason this was added in the first place was so popup components would close on page change, since otherwise they hang around without knowing about the page change -- but iframe components automatically close when the page is unloaded, so seems like doing a destroy here for iframes isn't really necessary.

That or we could just make the destroy happen on unload rather than beforeunload so the component doesn't disappear too soon?

mmairs9-zz commented 7 years ago

That makes sense to me to be non configurable and to not have the logic to destroy the component if it is an iframe.

harouny commented 7 years ago

+1 for only apply close component on page unload when coponent is a popup. Browsers should take care of closing the iframe.

harouny commented 7 years ago

On a related note, I think making this happen on '''unload''' is better than '''beforeUnload''' . I'm not sure what's the behavior if someone have this in the page that opened the popup to show a navigating away confirmation and user cancels navigation. ''' window.onbeforeunload = function() { return true; }; '"

harouny commented 7 years ago

sorry writing on mobile :(

bluepnume commented 7 years ago

Yeah it's a fair point. I think it was mainly just me not trusting unload enough to do everything I needed it to before the page unloads.

bluepnume commented 7 years ago

OK, made this change and published. Please let me know if it works ok for you. For now I've gone with the unload fix rather than branching the logic any further for popups vs iframes.

figalex commented 4 years ago

Is there currently a way to prevent a popup from being destroyed when parent is reloaded? We are trying to open a separate widget in a popup window that needs to persist while the user is navigating through different pages under our domain but as soon as the main (parent) page is reloaded or user clicks in a new link the popup is destroyed.