Skip to content

Commit 422389d

Browse files
committed
fix: more accurate initial heigth for VirtualElements + fallback fix in VirtualElement
1 parent c5f4c0a commit 422389d

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
@@ -2730,6 +2730,27 @@ const RundownViewContent = translateWithTracker<IPropsWithReady, IState, ITracke
27302730
const isLastSegment =
27312731
rundownIndex === rundownArray.length - 1 && segmentIndex === segmentArray.length - 1
27322732

2733+
// Calculate placeholder height based on segment properties
2734+
const calculatePlaceholderHeight = (segment: DBSegment): number => {
2735+
// Base height for a normal segment timeline
2736+
const BASE_SEGMENT_HEIGHT = 260
2737+
// Approximate height for dashboard panel (mini-shelf) when displayed
2738+
const DASHBOARD_PANEL_HEIGHT = 200
2739+
// Minimum height for hidden segments to prevent layout issues
2740+
const HIDDEN_SEGMENT_MIN_HEIGHT = 10
2741+
2742+
if (segment.isHidden) {
2743+
// Hidden segments don't render the timeline at all
2744+
// They only render the dashboard panel if showShelf is true
2745+
return segment.showShelf ? DASHBOARD_PANEL_HEIGHT : HIDDEN_SEGMENT_MIN_HEIGHT
2746+
}
2747+
2748+
// Normal segment: base timeline height + optional dashboard panel
2749+
return segment.showShelf ? BASE_SEGMENT_HEIGHT + DASHBOARD_PANEL_HEIGHT : BASE_SEGMENT_HEIGHT
2750+
}
2751+
2752+
const segmentPlaceholderHeight = calculatePlaceholderHeight(segment)
2753+
27332754
return (
27342755
<ErrorBoundary key={unprotectString(segment._id)}>
27352756
<VirtualElement
@@ -2739,8 +2760,8 @@ const RundownViewContent = translateWithTracker<IPropsWithReady, IState, ITracke
27392760
})}
27402761
id={SEGMENT_TIMELINE_ELEMENT_ID + segment._id}
27412762
margin={'100% 0px 100% 0px'}
2742-
initialShow={globalIndex++ < window.innerHeight / 260}
2743-
placeholderHeight={260}
2763+
initialShow={globalIndex++ < window.innerHeight / segmentPlaceholderHeight}
2764+
placeholderHeight={segmentPlaceholderHeight}
27442765
placeholderClassName="placeholder-shimmer-element segment-timeline-placeholder"
27452766
width="auto"
27462767
>

0 commit comments

Comments
 (0)