@@ -76,6 +76,11 @@ export function VirtualElement({
7676 marginLeft : measurements ?. marginLeft ,
7777 marginRight : measurements ?. marginRight ,
7878 marginBottom : measurements ?. marginBottom ,
79+ // These properties are used to ensure that if a prior element is changed from
80+ // placeHolder to element, the position of visible elements are not affected.
81+ contentVisibility : 'auto' ,
82+ containIntrinsicSize : `0 ${ measurements ?. clientHeight ?? placeholderHeight ?? '0' } px` ,
83+ contain : 'size layout' ,
7984 } ) ,
8085 [ width , measurements , placeholderHeight ]
8186 )
@@ -158,7 +163,13 @@ export function VirtualElement({
158163 const refreshSizingTimeout = window . setTimeout ( ( ) => {
159164 idleCallback = window . requestIdleCallback (
160165 ( ) => {
161- setMeasurements ( measureElement ( el ) )
166+ const newMeasurements = measureElement ( el )
167+ setMeasurements ( newMeasurements )
168+
169+ // Set CSS variable for expected height on parent element
170+ if ( ref && newMeasurements ) {
171+ ref . style . setProperty ( '--expected-height' , `${ newMeasurements . clientHeight } px` )
172+ }
162173 } ,
163174 {
164175 timeout : IDLE_CALLBACK_TIMEOUT ,
@@ -182,7 +193,17 @@ export function VirtualElement({
182193 className = { className }
183194 as = "div"
184195 >
185- < div ref = { setRef } >
196+ < div
197+ ref = { setRef }
198+ style = {
199+ // We need to set undefined if the height is not known, to allow the parent to calculate the height
200+ measurements
201+ ? {
202+ height : measurements . clientHeight + 'px' ,
203+ }
204+ : undefined
205+ }
206+ >
186207 { showPlaceholder ? (
187208 < div
188209 id = { measurements ?. id ?? id }
@@ -199,11 +220,26 @@ export function VirtualElement({
199220
200221function measureElement ( el : HTMLElement ) : IElementMeasurements | null {
201222 const style = window . getComputedStyle ( el )
202- const clientRect = el . getBoundingClientRect ( )
223+
224+ // Get children to be measured
225+ const segmentTimeline = el . querySelector ( '.segment-timeline' )
226+ const dashboardPanel = el . querySelector ( '.rundown-view-shelf.dashboard-panel' )
227+
228+ if ( ! segmentTimeline ) return null
229+
230+ // Segment height
231+ const segmentRect = segmentTimeline . getBoundingClientRect ( )
232+ let totalHeight = segmentRect . height
233+
234+ // Dashboard panel height if present
235+ if ( dashboardPanel ) {
236+ const panelRect = dashboardPanel . getBoundingClientRect ( )
237+ totalHeight += panelRect . height
238+ }
203239
204240 return {
205241 width : style . width || 'auto' ,
206- clientHeight : clientRect . height ,
242+ clientHeight : totalHeight ,
207243 marginTop : style . marginTop || undefined ,
208244 marginBottom : style . marginBottom || undefined ,
209245 marginLeft : style . marginLeft || undefined ,
0 commit comments