You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(Table): wire virtualizer.measureElement for dynamic row heights
Rebased on top of #6217's spacer-row structure.
- Bind virtualizer.measureElement as a template ref plus data-index on
the virtualized <tr> so TanStack Virtual observes it and invokes the
measureElement option. Without this the user's measureElement option
was typed but never called, blocking dynamic heights entirely (#6101).
- Stop forcing the virtualRow.size style on the main row so natural
content height is measurable; estimateSize becomes a true initial
guess only.
- Default measureElement adds the immediate next-sibling <tr>'s height
when data-expanded="true", so expansion rows are included in the
cached size. A user-supplied measureElement still measures the main
row; the expansion sum is layered on top.
- Forward the per-row :style to the expanded <tr> as well so it stays
adjacent to its main row under any future transform.
- Watcher on tableApi.getState().expanded diffs before/after and
re-measures only rows whose expanded flag toggled. Expand-all sentinel
(boolean true) falls back to a full sweep.
- JSDoc notes that TanStack's ResizeObserver is attached to the main
<tr> only — intra-expansion resizes (late-loading images, nested
toggles) need a manual virtualizer.measure() call.
- Docs: new 'Dynamic row heights' subsection with a measureElement
example and the auto-sum note for expanded rows.
Closes#6101.
`estimateSize` is only the initial guess — the virtualizer measures every rendered row and updates its internal size map as you scroll. For rows with variable content (expandable rows, rich text, images), pass a `measureElement` callback to read the actual rendered height:
When a row is expanded via `row.toggleExpanded()`, the expansion row's height is automatically added to the measurement — you don't need to walk siblings yourself.
706
+
689
707
### With tree data
690
708
691
709
You can use the `get-sub-rows` prop to display hierarchical (tree) data in the table.
0 commit comments