DynamicScroller (page-mode): ResizeObserver misses async row height changes, leaving stale sizes in cache and causing row overlap/gaps
Describe the bug
DynamicScroller + DynamicScrollerItem in page-mode intermittently fails to update vscrollData.sizes[id] after a mounted row's DOM height changes. The wrapper's offsetHeight is correct, but the ResizeObserver-driven measurement path doesn't fire (or is swallowed), so the layout keeps using the stale/initial size — producing overlapping rows or gaps.
- Are there known cases where the internal ResizeObserver misses size updates in
page-mode? - Would it be reasonable to expose a public
remeasureVisible()onDynamicScroller(equivalent of the workaround above) so consumers don't need to touch$_vs_id/$_vs_onResize?
Reproduction
Setup
<DynamicScroller
:items="items"
key-field="gtin"
:min-item-size="96"
page-mode
>
<template #default="{ item, active }">
<DynamicScrollerItem :item="item" :active="active">
<MyRow />
<FooterHint v-if="showHint(item)" /> <!-- appears async when data loads -->
</DynamicScrollerItem>
</template>
</DynamicScroller>- ~500 items, async-populated per-item data (Apollo).
FooterHintis rendered conditionally after the async data resolves for a row, growing the wrapper from 96 px → 120 px.
Steps to reproduce
- Mount the list; async data begins loading.
- Scroll into a range where several rows will show
FooterHint. - Observe layout while the async data lands.
Expected
Wrapper offsetHeight change (96 → 120) triggers the internal $_vs_onResize, vscrollData.sizes[id] is updated, following rows shift down. Layout is gap/overlap free.
Actual
- Wrapper
offsetHeightis correctly 120 px. - The
.vue-recycle-scroller__item-viewheight andtranslateYfor subsequent items are computed with the stale 96 px cache. - Result: rows overlap by ~24 px (or gap in the opposite direction after column resize).
- Same behavior after column-resize on parent grid: some pool items keep their old cached size even though their DOM offsetHeight has grown.
Layout snapshot (simplified):
item[0] y=2880 offsetHeight=120 layoutSize=120 ✔
item[1] y=3000 offsetHeight=120 layoutSize=96 ✘ overlap
item[2] y=3096 offsetHeight=120 layoutSize=96 ✘ overlapNotes / probable cause
- ResizeObserver is attached (
wrapper.$_vs_idandwrapper.$_vs_onResizeare set on the inner div). - Manually calling
wrapper.$_vs_onResize(wrapper.$_vs_id, w, h)for each mounted.vue-recycle-scroller__item-viewimmediately corrects the layout — soV()→W()→vscrollData.sizes[id] = hworks fine when it's invoked. The RO callback simply isn't firing for these size changes. - This happens most often when:
- the wrapper's first ResizeObserver observation happened before the async content mutation, and
- the mutation happens while the parent (
bobmono-ica-tablecustom element with grid-template-columns) is also relayouting.
forceUpdate(true)makes it worse: it resets every row tomin-item-sizebut the RO still doesn't re-measure, so the whole list collapses tomin-item-sizeheight.
Workaround
After column-resize, compact-toggle, and on useScroll idle, iterate the mounted pool and re-invoke $_vs_onResize with the current offsetHeight:
scrollerEl.querySelectorAll('.vue-recycle-scroller__item-view').forEach((iv) => {
const wrapper = iv.firstElementChild;
wrapper?.$_vs_onResize?.(wrapper.$_vs_id, wrapper.offsetWidth, wrapper.offsetHeight);
});This is obviously reaching into internal properties and shouldn't be necessary.
System Info
`[email protected]`, Vue 3.5, Chrome/Safari on macOS.Used Package Manager
npm
Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Source: Akryum/vue-virtual-scroller