Skip to content

Commit 48c0c8d

Browse files
committed
fix: take unknown elements into account
1 parent a0a421d commit 48c0c8d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ export function VirtualElement({
8080
const styleObj = useMemo<React.CSSProperties>(
8181
() => ({
8282
width: width ?? 'auto',
83-
height: (placeholderHeight ?? '0') + 'px',
83+
height: ((placeholderHeight || ref?.clientHeight) ?? '0') + 'px',
8484
marginTop: 0,
8585
marginLeft: 0,
8686
marginRight: 0,
8787
marginBottom: 0,
8888
// These properties are used to ensure that if a prior element is changed from
8989
// placeHolder to element, the position of visible elements are not affected.
9090
contentVisibility: 'auto',
91-
containIntrinsicSize: `0 ${placeholderHeight ?? '0'}px`,
91+
containIntrinsicSize: `0 ${(placeholderHeight || ref?.clientHeight) ?? '0'}px`,
9292
contain: 'size layout',
9393
}),
9494
[width, placeholderHeight]
@@ -368,20 +368,16 @@ function measureElement(wrapperEl: HTMLDivElement, placeholderHeight?: number):
368368
const el = wrapperEl.firstElementChild as HTMLElement
369369
const style = window.getComputedStyle(el)
370370

371-
const timelineWrapper = el.closest('.segment-timeline-wrapper--shelf')
371+
let segmentTimeline: Element | null = null
372+
let dashboardPanel: Element | null = null
372373

373-
if (timelineWrapper) {
374-
let totalHeight = 0
374+
segmentTimeline = wrapperEl.querySelector('.segment-timeline')
375+
dashboardPanel = wrapperEl.querySelector('.dashboard-panel')
375376

376-
// Get the segment timeline height
377-
const segmentTimeline = timelineWrapper.querySelector('.segment-timeline')
378-
if (segmentTimeline) {
379-
const segmentRect = segmentTimeline.getBoundingClientRect()
380-
totalHeight = segmentRect.height
381-
}
377+
if (segmentTimeline) {
378+
const segmentRect = segmentTimeline.getBoundingClientRect()
379+
let totalHeight = segmentRect.height
382380

383-
// Add the dashboard panel height if it exists
384-
const dashboardPanel = timelineWrapper.querySelector('.dashboard-panel')
385381
if (dashboardPanel) {
386382
const panelRect = dashboardPanel.getBoundingClientRect()
387383
totalHeight += panelRect.height

0 commit comments

Comments
 (0)