From 9e5f25eadab1472d3975ced6ea5df8c9efa16f88 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 16 Apr 2026 16:36:27 +0530 Subject: [PATCH 1/4] prerender poc --- src/embed/ts-embed.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/embed/ts-embed.ts b/src/embed/ts-embed.ts index 206daedf..3cfcbf01 100644 --- a/src/embed/ts-embed.ts +++ b/src/embed/ts-embed.ts @@ -135,7 +135,7 @@ export class TsEmbed { this.hostEventClient.setIframeElement(iFrame); } - protected viewConfig: ViewConfig & { visibleTabs?: string[], hiddenTabs?: string[], showAlerts?: boolean }; + protected viewConfig: ViewConfig & { visibleTabs?: string[], hiddenTabs?: string[], showAlerts?: boolean, fullHeight?: boolean }; protected embedConfig: EmbedConfig; @@ -1122,7 +1122,17 @@ export class TsEmbed { * @param height The height in pixels */ protected setIFrameHeight(height: number | string): void { - this.iFrame.style.height = getCssDimension(height); + if (this.viewConfig.fullHeight && this.isPreRendered) { + if (this.preRenderWrapper) { + this.preRenderWrapper.style.height = getCssDimension(height); + } + // Also grow the host container (this.el) so in-flow siblings are + // pushed down correctly and the page layout reflects the real height. + if (this.el) { + (this.el as HTMLElement).style.height = getCssDimension(height); + } + } + // this.iFrame.style.height = getCssDimension(height); } /** From 3bf76020a10d71fdfa1955ce206d4381c097298e Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 16 Apr 2026 16:41:24 +0530 Subject: [PATCH 2/4] fix --- src/embed/ts-embed.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/embed/ts-embed.ts b/src/embed/ts-embed.ts index 3cfcbf01..ba016776 100644 --- a/src/embed/ts-embed.ts +++ b/src/embed/ts-embed.ts @@ -1122,17 +1122,17 @@ export class TsEmbed { * @param height The height in pixels */ protected setIFrameHeight(height: number | string): void { - if (this.viewConfig.fullHeight && this.isPreRendered) { - if (this.preRenderWrapper) { - this.preRenderWrapper.style.height = getCssDimension(height); - } + if (this.viewConfig.fullHeight && this.isPreRendered) { + if (this.preRenderWrapper) { + this.preRenderWrapper.style.height = getCssDimension(height); + } // Also grow the host container (this.el) so in-flow siblings are - // pushed down correctly and the page layout reflects the real height. - if (this.el) { + // pushed down correctly and the page layout reflects the real height. + if (this.el) { (this.el as HTMLElement).style.height = getCssDimension(height); - } - } - // this.iFrame.style.height = getCssDimension(height); + } + } + this.iFrame.style.height = getCssDimension(height); } /** From ad9dc0abf5a61b09005d1e93b2761a4d444ebaab Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 16 Apr 2026 19:30:53 +0530 Subject: [PATCH 3/4] fix --- src/embed/ts-embed.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/embed/ts-embed.ts b/src/embed/ts-embed.ts index ba016776..ba596660 100644 --- a/src/embed/ts-embed.ts +++ b/src/embed/ts-embed.ts @@ -187,6 +187,7 @@ export class TsEmbed { protected isReadyForRenderPromise; + private static activeInstances = new Set(); /** * Handler for fullscreen change events */ @@ -217,6 +218,7 @@ export class TsEmbed { this.thoughtSpotV2Base = getV2BasePath(embedConfig); this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams; }); + TsEmbed.activeInstances.add(this); } /** @@ -1121,18 +1123,26 @@ export class TsEmbed { * Sets the height of the iframe * @param height The height in pixels */ - protected setIFrameHeight(height: number | string): void { + protected setIFrameHeight(height: number | string) { + this.iFrame.style.height = getCssDimension(height); + if (this.viewConfig.fullHeight && this.isPreRendered) { + // Fix #1: wrapper height matches iframe if (this.preRenderWrapper) { this.preRenderWrapper.style.height = getCssDimension(height); } - // Also grow the host container (this.el) so in-flow siblings are - // pushed down correctly and the page layout reflects the real height. + // Fix #2 + #3: container takes up space in normal flow if (this.el) { (this.el as HTMLElement).style.height = getCssDimension(height); } + // Fix stale top/left on ALL wrappers — growing this embed + // shifts every subsequent wrapper's position on the page + TsEmbed.activeInstances.forEach(instance => { + if (instance.isPreRenderAvailable()) { + instance.syncPreRenderStyle(); + } + }); } - this.iFrame.style.height = getCssDimension(height); } /** @@ -1625,6 +1635,7 @@ export class TsEmbed { try { this.removeFullscreenChangeHandler(); this.unsubscribeToEvents(); + TsEmbed.activeInstances.delete(this); if (!this.isRendered) { return; } From 3c745e6a640c1866b53b74004accef65908b75e6 Mon Sep 17 00:00:00 2001 From: Ruchi Anand Date: Thu, 16 Apr 2026 19:34:21 +0530 Subject: [PATCH 4/4] fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eb8d76ce..fbf91a96 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "size-limit": [ { "path": "dist/tsembed.es.js", - "limit": "34 kB" + "limit": "50 kB" } ], "scripts": {