(
el: HTMLElement,
streaming: boolean,
options?: { domUpdated?: boolean },
)
| 28 | * inner overflow (e.g. max-height grids) cannot trap page scroll. |
| 29 | */ |
| 30 | export function lockStreamHeight( |
| 31 | el: HTMLElement, |
| 32 | streaming: boolean, |
| 33 | options?: { domUpdated?: boolean }, |
| 34 | ): void { |
| 35 | if (!streaming) { |
| 36 | el.style.minHeight = ""; |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | const domUpdated = options?.domUpdated !== false; |
| 41 | const h = el.offsetHeight; |
| 42 | const prev = Number.parseFloat(el.style.minHeight) || 0; |
| 43 | |
| 44 | if (h > prev) { |
| 45 | el.style.minHeight = `${h}px`; |
| 46 | } else if (domUpdated && h < prev) { |
| 47 | el.style.minHeight = h > 0 ? `${h}px` : ""; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** Clear height lock when streaming finishes */ |
| 52 | export function unlockStreamHeight(el: HTMLElement): void { |
no outgoing calls
no test coverage detected