|
215 | 215 | frameWidth: rect ? Math.round(rect.width) : null, |
216 | 216 | frameHeight: rect ? Math.round(rect.height) : null, |
217 | 217 | ...(collapsed ? { collapsedAncestors: describeCollapsedAncestors(frame) } : {}), |
| 218 | + ...(healAttempts > 0 ? { healAttempts } : {}), |
218 | 219 | ...report |
219 | 220 | }); |
220 | 221 | } |
221 | 222 |
|
| 223 | + const MAX_HEAL_ATTEMPTS = 2; |
| 224 | + let healAttempts = 0; |
| 225 | +
|
| 226 | + // Safari 27.0 can leave a frame inserted by client-side navigation at 0×0 despite a definite height, until a window resize forces a fresh layout. |
| 227 | + function healCollapsedFrame(): void { |
| 228 | + const frame = iframeEl; |
| 229 | + const container = frame?.parentElement; |
| 230 | + if (!frame || !container || !frame.isConnected || healAttempts >= MAX_HEAL_ATTEMPTS) return; |
| 231 | + const definiteHeight = height ?? (minHeight ? Math.max(minHeight, reportedHeight) : 0); |
| 232 | + if (definiteHeight <= 0) return; |
| 233 | + if (frame.getBoundingClientRect().height > 0) return; |
| 234 | + // Charts inside closed tabs, accordions or other hidden sections are legitimately 0×0. |
| 235 | + if (!frame.checkVisibility?.()) return; |
| 236 | + healAttempts++; |
| 237 | + container.style.display = 'none'; |
| 238 | + void container.offsetHeight; |
| 239 | + container.style.removeProperty('display'); |
| 240 | + requestAnimationFrame(healCollapsedFrame); |
| 241 | + } |
| 242 | +
|
222 | 243 | function completeRenderTask(): void { |
223 | 244 | markRenderComplete?.(); |
224 | 245 | markRenderComplete = undefined; |
|
236 | 257 | onError?.(undefined); |
237 | 258 | onRendered?.(); |
238 | 259 | completeRenderTask(); |
| 260 | + requestAnimationFrame(healCollapsedFrame); |
239 | 261 | return; |
240 | 262 | case 'height': { |
241 | 263 | // Drop bad payloads (NaN/Infinity/negative/non-number) — they'd |
|
0 commit comments