laneAssignmentMode 'measured': is it intended that a row measured at exactly its estimate can change lanes?

オープン
#1,379 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
react, typescript
領域
frontend

調査の方向性

Start in tests/index.test.ts, which the issue names as the place that reads the private measurement method, and trace how resizeItem handles sizes equal to estimateSize in measured lane assignment. Add a regression case based on the reproducer, then check whether lanes remain stable after row 1 grows; the issue leaves the intended behavior unresolved, so confirm that before changing behavior.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

With lanes > 1 and laneAssignmentMode: 'measured', a row whose first measurement exactly equals estimateSize doesn't get its lane cached, because resizeItem records a measurement only when the size changes. When a row above it grows later, that row is placed again and can move to another lane. A row measured at any other size keeps its lane.

Start: 8 rows in lanes 0 1 0 1 0 1 0 1. As-is: four rows move to another lane when row 1 grows. To-be: no row moves.
Your minimal, reproducible example
import { Virtualizer } from '@tanstack/virtual-core'

const measureThenGrow = (height: number) => {
  const virtualizer = new Virtualizer({
    count: 8,
    lanes: 2,
    estimateSize: () => 100,
    laneAssignmentMode: 'measured',
    getScrollElement: () => null,
    scrollToFn: () => {},
    observeElementRect: () => {},
    observeElementOffset: () => {},
  })
  // getMeasurements is private; tests/index.test.ts reads it the same way.
  const lanes = () =>
    virtualizer['getMeasurements']().map((m) => m.lane).join(' ')

  lanes() // Build the measurements first; resizeItem needs them.
  for (let i = 0; i < 8; i++) virtualizer.resizeItem(i, height)
  const measured = lanes()
  virtualizer.resizeItem(1, 500)
  return { measured, grown: lanes() }
}

console.log(measureThenGrow(100))
// { measured: '0 1 0 1 0 1 0 1', grown: '0 1 0 0 0 0 1 0' }
console.log(measureThenGrow(101))
// { measured: '0 1 0 1 0 1 0 1', grown: '0 1 0 1 0 1 0 1' }
Steps to reproduce
  1. Run the example above.
  2. At 100, row 1 growing moves rows 3, 5, 6 and 7 to another lane.
  3. At 101, every row keeps its lane.
Expected behavior

I can't tell which behavior is intended, so I'd like to ask before going further.

  • If this is not intended, a row measured at exactly its estimate should keep its lane like any other measured row, since the docs say lanes are cached and remain stable after the initial measurement. #1377 is a draft of that fix.
  • If this is intended, for example so that a placeholder sized like the estimate can rebalance once its content loads, there is nothing to fix and I'll close #1377.

Is this behavior intended?

How often does this bug happen?

Every time

Platform

Any. This is in virtual-core.

tanstack-virtual version

3.19.11

TypeScript version

n/a

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
主要言語
TypeScript
スター
7.2k
フォーク
495
平均マージ
23時間 16分
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/virtual のほかの issue

TanStack/virtual の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。