fix(virtual-core): scroll to index in dynamic, add warning about smoo… · TanStack/virtual@7eb8e6a · GitHub
Skip to content

Commit 7eb8e6a

Browse files
authored
fix(virtual-core): scroll to index in dynamic, add warning about smooth behavior (#469)
1 parent 89f4380 commit 7eb8e6a

3 files changed

Lines changed: 133 additions & 59 deletions

File tree

‎examples/react/dynamic/src/main.tsx‎

Lines changed: 51 additions & 25 deletions

‎packages/react-virtual/__tests__/index.test.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ function List({
4040
rangeExtractor,
4141
})
4242

43+
const measureElement = dynamic ? rowVirtualizer.measureElement : undefined
44+
4345
return (
4446
<div
4547
ref={parentRef}
@@ -58,9 +60,7 @@ function List({
5860
data-testid={`item-${virtualRow.key}`}
5961
key={virtualRow.key}
6062
data-index={virtualRow.index}
61-
ref={(el) =>
62-
dynamic ? rowVirtualizer.measureElement(el) : undefined
63-
}
63+
ref={measureElement}
6464
style={{
6565
position: 'absolute',
6666
top: 0,

‎packages/virtual-core/src/index.ts‎

Lines changed: 79 additions & 31 deletions

0 commit comments

Comments
 (0)