This adds a guestinstance attribute to webviews. When the webview first loads it updates its guestinstance with the instance ID for the webcontents. Setting the attribute to an existing guestinstance moves the webcontents to the new webview and sends a destroy event on the original webview. This fixes #1871.
This also adds the did-attach event since it is useful for detecting when the move is complete and I think that that fixes #6972 as did-attach is sent for the first navigation too.
Add a guestinstance attribute to webviews reflecting their current guest
instance ID and allowing moving a guest instance to a new webview.
This is awesome. 👍
@Mossop I can't figure out whether this is of interest to me - what real world coolness does this enable? Dragging content between BrowserWindow?
Ok I have now read #1871 but would like to see a code or pseudo-code example of a recommended approach.
@TimNZ The tests show some examples but basically if you take the value of the guestinstance attribute from an active webview and set it on a different webview, even in a different BrowserWindow, then the content will move to the new webview and the old will receive a destroy event.
Thanks, was just reading through the tests now. I guess there is still limitations around implementing a similar tab drag into new window like a browser as we don't have the native GUI mechanism in Electron to do it?
@TimNZ It's doable with html5 drag and drop APIs but you would of course have to write the app code yourself.
@Mossop Cool thanks. I'm building a business app MVP and not strong on HTML5, will have an expert doing that stuff. Great work!
Could it be possible to duplicate/clone the webcontents? i.e., not 'destroy' the existing window?
I created an issue for this a few months ago at #6063. Is something like this definitely not feasible? It could be a game-changer for multi-window electron apps if something like this was possible.
@davej I can't say for certain that it's impossible but at the very least I think it would be extremely difficult to achieve that.