Skip to content

fix: arrow key navigation causes white blank area in virtual scroll (#5105)#5113

Open
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Erica-cod:fix/arrow-key-scroll-blank-area
Open

fix: arrow key navigation causes white blank area in virtual scroll (#5105)#5113
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Erica-cod:fix/arrow-key-scroll-blank-area

Conversation

@Erica-cod
Copy link
Copy Markdown
Contributor

@Erica-cod Erica-cod commented Apr 15, 2026

🤔 这个分支是...

  • 新功能
  • Bug fix
  • Ts 类型更新
  • 打包优化
  • 性能优化
  • 功能增强
  • 重构
  • 依赖版本更新
  • 代码优化
  • 测试 case 更新
  • 分支合并
  • 网站/文档更新
  • demo 更新
  • Workflow
  • 配置修改
  • 发布
  • 其他 (具体是什么,请补充?)

🔗 相关 issue 连接

close #5105

💡 问题的背景&解决方案

问题描述: 使用方向键导航单元格超出可视区域时,表格出现白色空白区域。

根因分析: 发现两个互相关联的问题:

  1. dynamicSetX/dynamicSetY 提前返回问题:screenLeft/screenTopnull(因 getTargetColAt 浮点精度问题导致)时,函数直接 return,没有更新 body group 的位置也没有触发重新渲染,导致视图停留在旧的位置,呈现为白色空白。

  2. setBodyAndColHeaderX/setBodyAndRowHeaderY 边界校正问题: 直接取 bodyGroup.lastChild 作为最后一个列组使用,但虚拟滚动过程中 lastChild 可能是 border 元素(通过 appendChild 重新挂载到末尾),导致滚动边界校正逻辑使用了错误的列/行位置信息。

修复方案:

  • dynamicSetX:即使 screenLeftnull,仍调用 setBodyAndColHeaderX 更新位置并触发渲染
  • dynamicSetY:同理,screenTopnull 时仍调用 updateBody 并触发渲染
  • setBodyAndColHeaderX:对 lastChild 增加单次 if 检查,跳过 border 元素取真正的列组(O(1) 操作,border 始终为最后一个子元素)
  • setBodyAndRowHeaderY:同样对 lastChild 增加 border 过滤

WHY 如此修复?
同时考虑到可能的性能开销问题,判断时候尽量减少while

demo截图
image

📝 Changelog

Language Changelog
🇺🇸 English Fix white blank area when navigating cells with arrow keys in virtual scroll mode
🇨🇳 Chinese 修复虚拟滚动模式下使用方向键导航单元格时出现白色空白区域的问题

☑️ 自测

⚠️ 在提交 PR 之前,请检查一下内容。⚠️

  • 文档提供了,或者更新,或者不需要
  • Demo 提供了,或者更新,或者不需要
  • Ts 类型定义提供了,或者更新,或者不需要
  • Changelog 提供了,或者不需要

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

dynamicSetX/dynamicSetY returned early when screenLeft/screenTop
was null, leaving body group position stale.
setBodyAndColHeaderX/setBodyAndRowHeaderY could incorrectly
read border element as lastChild.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] @visactor/vtable-sheet 组件使用方向键向右移动单元格,出现白色空白区域

1 participant