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

SolidJS: warning "Missing attribute name 'data-index={index}' on measured element."

未关闭
#930 3 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
typescript

调研方向

从链接的 CodeSandbox 复现开始,检查 SolidJS 对 virtualizer.measureElement 的使用,尤其是 issue 中显示的 data-index 和 ref 属性。跟踪测量回调如何读取元素,并将其与先分配 el.dataset.index 的变通方案进行比较。当复现不再发出缺少属性的警告,同时测量仍能正常工作时,即表示完成。

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

描述

Describe the bug

Looks like virtualizer.measureElement is not working with SolidJS

<For each={virtualizer.getVirtualItems()}>{(item) =>
	<div
		class={item.index % 2 ? 'ListItemOdd' : 'ListItemEven'}
		data-index={item.index}
		ref={virtualizer.measureElement}
		style={{
			border: "1px solid red",
			"box-sizing": "border-box",
			"height": "150px"
		}}
	>
		Row {item.index} 
	</div>
}</For>

Dirty workaround:

<For each={virtualizer.getVirtualItems()}>{(item) =>
	<div
		class={item.index % 2 ? 'ListItemOdd' : 'ListItemEven'}
		data-index={item.index}
		ref={(el) => {
			el.dataset.index = item.index.toString(); // <--- see this!
			virtualizer.measureElement(el);
		}}
		style={{
			border: "1px solid red",
			"box-sizing": "border-box",
			"height": "150px"
		}}
	>
		Row {item.index} {Date.now()}
	</div>
}</For>
Your minimal, reproducible example

https://codesandbox.io/p/devbox/9rkhxf

Steps to reproduce

Just add

data-index={item.index}
ref={virtualizer.measureElement}
Expected behavior

No warning

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

Chromium 133.0.6943.98

tanstack-virtual version

3.13.0

TypeScript version

No response

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 分钟
30 天内合并 PR
13

贡献指南

打开贡献指南

从这里开始

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

TanStack/virtual 的其他 Issue

查看 TanStack/virtual 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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