Fix widget persistence in React development mode (#30509)

15f1291cbc was really close to making widgets just work again in React development mode following the upgrade to React 19, but I forgot to test one thing: that persistent widgets (such as Element Call) still reuse the same iframe across their entire lifecycle as expected. The solution is to not manually destroy the iframe when AppTile is being unmounted; even if it turns out that the widget isn't actually persistent, React will still destroy it automatically for us.
This commit is contained in:
Robin
2025-08-07 09:44:20 +02:00
committed by GitHub
parent d7f54355ac
commit f9a0a626a6

View File

@@ -445,11 +445,12 @@ export default class AppTile extends React.Component<IProps, IState> {
* Callback ref for the parent div of the iframe.
*/
private iframeParentRef = (element: HTMLElement | null): void => {
if (this.unmounted) return;
// Detach the existing iframe (if any) from the document so we know not
// to do anything further with it, like starting up the messaging
this.iframeParent?.querySelector("iframe")?.remove();
this.iframeParent = element;
if (this.unmounted) return;
if (element && this.sgWidget) {
this.startMessaging();
} else {