`useVirtualizer({paddingEnd: 800})` creates overscroll issue with `scrollToIndex(last)`
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
リンクされた最小再現から始め、useVirtualizer と scrollToIndex のエントリポイントを追跡し、paddingEnd と last-index の挙動に注目してください。提供されているボタンで問題を再現し、最後のインデックスまでスクロールしたときに、コンテナを過剰にスクロールさせずに項目が完全に表示されたままになることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The paddingEnd option for the useVirtualizer callback is not correctly taken into account when using rowVirtualizer .scrollToIndex(last). Instead the function call scrolls to the end of the scroll container. For every other index this works as intended.
const rowVirtualizer = useVirtualizer({
count: 100,
getScrollElement: () => parentRef.current,
estimateSize: () => 35,
overscan: 5,
paddingEnd: 800
})
// ...
<button onClick={() => {
rowVirtualizer.scrollToIndex(98)
}}>
Scroll to 98 (works)
</button>
<button onClick={() => {
rowVirtualizer.scrollToIndex(99)
}}>
Scroll to 99 (overscrolls)
</button>
Your minimal, reproducible example
https://github.com/Freymaurer/tanstack-virtual-padding-overscroll-bug-example
Steps to reproduce
- Clone and
npm i->npm run devthe example (fresh vite-react-ts with tanstack virtual dependency) -> open the link printed to console - Click the buttons i added on top of the view
- "Back to Start" uses
scrollToIndex(0) - "Scroll to 98 (works)" scrolls to 98, so not last index
- "Scroll to 99 (overscrolls)" scrolls to the last index
- Click on "Back to Start", then "Scroll to 98 (works)". It scrolls with pretty good alignment. The field is shown on the bottom of the scrollContainer
- Click on "Back to Start", then "Scroll to 99 (overscrolls)". It overscrolls, the element is not visible on screen. 🐛 I think this is due the library calling more or less "scrollToEnd" instead of "scrollTo" in this scenario.
Expected behavior
I expected the behavior to be consistent. The element at last index should be fully visible after calling the scroll function, instead of scrolling to the scroll container end
How often does this bug happen?
Every time
Screenshots or Videos
After clicking on "Scroll to 98 (works)"
After clicking on "Scroll to 99 (overscrolls)"
Platform
OS: Windows 11
Browser: Tested on Chrome, Edge, Firefox, Opera
tanstack-virtual version
v3.14.9
TypeScript version
v6.0.3
Additional context
No response
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- 主要言語
- TypeScript
- スター
- 7.1k
- フォーク
- 466
- 平均マージ
- 2日 31分
- マージ済み PR(30日)
- 13
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/virtual のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
TanStack/virtual の issue をすべて見る
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100