Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

virtual-core: a clamp retry can overwrite a scroll command and ignores _canWriteScroll()

未关闭
#1,327 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript

调研方向

Start in the virtual-core scroll write path: _retryClampedAdjustment, _canWriteScroll, _startScroll, _writeAwaitingCommand, and the _willUpdate and resizeItem calls that grow the sizer. Reproduce the case where a clamped retry at { target: 4850, maxAtWrite: 4800 } fires after a scrollToIndex write to 550. Done when a command's target is never overwritten by a retry, the retry respects _canWriteScroll(), and tests cover desktop and the iOS 27 tail timer.

由索引模型根据 Issue 内容生成。

描述

Problem

_retryClampedAdjustment repeats a compensation write that the browser clamped because the sizer was not big enough yet (#1258). It has two problems.

1. The retry can overwrite a scroll command
  1. A hold flush or a compensation write is clamped. The virtualizer records a retry, for example { target: 4850, maxAtWrite: 4800 }.
  2. A scroll command writes. For example, scrollToIndex writes 550.
  3. _willUpdate or resizeItem runs before the command's read-back. The sizer is now bigger, so the retry writes 4850.

The scroll position is 4850, not the target of the command.

  • This occurs on desktop and on iOS.
  • On iOS 27 it occurs more often. The tail timer flushes the hold and then writes a queued command in the same task.
  • It occurs only with adapters whose notify does not grow the sizer synchronously. The React adapter grows it synchronously.
  • #1324 fixed this for a queued command: _writeAwaitingCommand clears the retry. Other commands still have the problem.
2. The retry ignores _canWriteScroll()

The retry can write during the iOS touch tail or under a finger that drags. iOS ignores a write under a finger. On iOS 26 and earlier, a write during the tail stops the momentum.

Possible fix

  • Clear _clampedAdjustment when a command starts (_startScroll), or skip the retry while scrollState !== null.
  • In _retryClampedAdjustment, return early when _canWriteScroll() is false. Keep the record for the next opportunity.
  • Add tests for desktop and for the iOS 27 tail timer.

Found during the review of #1324. Related: #1258, #1307.

主要语言
TypeScript
星标
7.1k
派生
472
平均合并
1 天 3 小时
30 天内合并 PR
31

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/virtual 的其他 Issue

查看 TanStack/virtual 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。