Skip to content

Commit d28698f

Browse files
committed
fix(Table): include expanded row height when measuring virtualized rows
When a row renders an expanded sibling `<tr>` (`row.getIsExpanded()`), the virtualizer measures only the primary `<tr>` and misses the expansion, causing `getTotalSize()` to under-report and the footer `translateY` offset to drift. Provide a default `measureElement` that, when the measured element has `data-expanded="true"`, also adds the immediate next `<tr>` sibling's height. A user-supplied `measureElement` still takes precedence for the primary row — the expansion sum is layered on top. Addresses CodeRabbit review feedback on nuxt#6379.
1 parent c1ff5b8 commit d28698f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/runtime/components/Table.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,17 @@ const virtualizer = !!props.virtualize && useVirtualizer({
439439
estimateSize: (index: number) => {
440440
const estimate = virtualizerProps.value.estimateSize
441441
return typeof estimate === 'function' ? estimate(index) : estimate
442+
},
443+
measureElement: (el, entry, instance) => {
444+
const userMeasure = virtualizerProps.value.measureElement
445+
const base = userMeasure
446+
? userMeasure(el, entry, instance)
447+
: Math.round(entry?.borderBoxSize?.[0]?.blockSize ?? (el as HTMLElement).offsetHeight)
448+
if ((el as Element).getAttribute('data-expanded') === 'true') {
449+
const next = (el as Element).nextElementSibling as HTMLElement | null
450+
if (next && next.tagName === 'TR') return base + next.offsetHeight
451+
}
452+
return base
442453
}
443454
})
444455

0 commit comments

Comments
 (0)