From b43a0c1557a8764d4d3f8c738686a8104aec4944 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaiets Date: Thu, 17 Sep 2026 15:32:45 -0500 Subject: [PATCH] SITES-49454: [Extensibility] Host issues affects RTE loading on CFE --- .../src/components/Extensible.test.tsx | 29 ++++++++++++++++++- .../src/components/Extensible.tsx | 9 ++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/uix-host-react/src/components/Extensible.test.tsx b/packages/uix-host-react/src/components/Extensible.test.tsx index e0c46f9..70642aa 100644 --- a/packages/uix-host-react/src/components/Extensible.test.tsx +++ b/packages/uix-host-react/src/components/Extensible.test.tsx @@ -104,7 +104,7 @@ describe("Extensible", () => { }); }); - it("should not call unload if host was never created", () => { + it("should still create a host when extensions resolve empty, and unload it on unmount", async () => { const extensionsProvider = jest.fn().mockResolvedValue({}); const { unmount } = render( @@ -113,6 +113,33 @@ describe("Extensible", () => { ); + // The host must exist even with zero extensions, so consumers relying on + // host readiness (e.g. useHost/loading state) aren't stuck waiting forever. + await waitFor(() => { + expect(MockedHost).toHaveBeenCalled(); + }); + + // load() must not be called since there is nothing to load + expect(mockLoad).not.toHaveBeenCalled(); + + unmount(); + + await waitFor(() => { + expect(mockUnload).toHaveBeenCalled(); + }); + }); + + it("should not call unload if the extensions fetch never resolved before unmount", () => { + const extensionsProvider = jest + .fn() + .mockReturnValue(new Promise(() => {})); + + const { unmount } = render( + +
Test Child
+
+ ); + unmount(); // Unload should not be called if host was never created diff --git a/packages/uix-host-react/src/components/Extensible.tsx b/packages/uix-host-react/src/components/Extensible.tsx index c60498b..5bc58d6 100644 --- a/packages/uix-host-react/src/components/Extensible.tsx +++ b/packages/uix-host-react/src/components/Extensible.tsx @@ -188,11 +188,16 @@ export function Extensible({ }; } - if (!extensions || !Object.keys(extensions).length) { + if (!extensionListFetched) { return; } + const hasExtensions = !!extensions && !!Object.keys(extensions).length; + const loadExtensions = (hostInstance: Host) => { + if (!hasExtensions) { + return; + } hostInstance .load(extensions, guestOptions) .catch(logError("Load of extensions failed!")); @@ -220,7 +225,7 @@ export function Extensible({ } else { loadExtensions(host); } - }, [debug, hostName, runtimeContainer, extensions]); + }, [debug, hostName, runtimeContainer, extensions, extensionListFetched]); const contextValue = useMemo( () => ({ host, extensionListFetched }),