Skip to content

Commit f251cd4

Browse files
olzzonrjmunro
authored andcommitted
fix: more accurate initial heigth for VirtualElements + fallback fix in VirtualElement
1 parent 6fe3507 commit f251cd4

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

packages/webui/src/client/lib/VirtualElement.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,22 @@ export function VirtualElement({
338338
>
339339
<div
340340
ref={setRef}
341+
id={id}
341342
style={
342-
// We need to set undefined if the height is not known, to allow the parent to calculate the height
343+
// Use measurements if available, otherwise fall back to placeholder/ref height when virtualized
343344
measurements
344345
? {
345346
height: measurements.clientHeight + 'px',
346347
}
348+
: !isShowingChildren
349+
? {
350+
height: ((placeholderHeight || ref?.clientHeight) ?? 0) + 'px',
351+
}
347352
: undefined
348353
}
349354
>
350355
{!isShowingChildren ? (
351356
<div
352-
id={measurements?.id ?? id}
353357
className={`virtual-element-placeholder ${placeholderClassName}`}
354358
style={styleObj}
355359
></div>

packages/webui/src/client/ui/RundownView.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,27 @@ const RundownViewContent = translateWithTracker<IPropsWithReady & ITrackedProps,
10061006
const isLastSegment =
10071007
rundownIndex === rundownArray.length - 1 && segmentIndex === segmentArray.length - 1
10081008

1009+
// Calculate placeholder height based on segment properties
1010+
const calculatePlaceholderHeight = (segment: DBSegment): number => {
1011+
// Base height for a normal segment timeline
1012+
const BASE_SEGMENT_HEIGHT = 260
1013+
// Approximate height for dashboard panel (mini-shelf) when displayed
1014+
const DASHBOARD_PANEL_HEIGHT = 200
1015+
// Minimum height for hidden segments to prevent layout issues
1016+
const HIDDEN_SEGMENT_MIN_HEIGHT = 10
1017+
1018+
if (segment.isHidden) {
1019+
// Hidden segments don't render the timeline at all
1020+
// They only render the dashboard panel if showShelf is true
1021+
return segment.showShelf ? DASHBOARD_PANEL_HEIGHT : HIDDEN_SEGMENT_MIN_HEIGHT
1022+
}
1023+
1024+
// Normal segment: base timeline height + optional dashboard panel
1025+
return segment.showShelf ? BASE_SEGMENT_HEIGHT + DASHBOARD_PANEL_HEIGHT : BASE_SEGMENT_HEIGHT
1026+
}
1027+
1028+
const segmentPlaceholderHeight = calculatePlaceholderHeight(segment)
1029+
10091030
return (
10101031
<ErrorBoundary key={unprotectString(segment._id)}>
10111032
<VirtualElement
@@ -1015,8 +1036,8 @@ const RundownViewContent = translateWithTracker<IPropsWithReady & ITrackedProps,
10151036
})}
10161037
id={SEGMENT_TIMELINE_ELEMENT_ID + segment._id}
10171038
margin={'100% 0px 100% 0px'}
1018-
initialShow={globalIndex++ < window.innerHeight / 260}
1019-
placeholderHeight={260}
1039+
initialShow={globalIndex++ < window.innerHeight / segmentPlaceholderHeight}
1040+
placeholderHeight={segmentPlaceholderHeight}
10201041
placeholderClassName="placeholder-shimmer-element segment-timeline-placeholder"
10211042
width="auto"
10221043
>

0 commit comments

Comments
 (0)