fix: arrow key navigation causes white blank area in virtual scroll (#5105)#5113
Open
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Open
fix: arrow key navigation causes white blank area in virtual scroll (#5105)#5113Erica-cod wants to merge 1 commit intoVisActor:developfrom
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 这个分支是...
🔗 相关 issue 连接
close #5105
💡 问题的背景&解决方案
问题描述: 使用方向键导航单元格超出可视区域时,表格出现白色空白区域。
根因分析: 发现两个互相关联的问题:
dynamicSetX/dynamicSetY提前返回问题: 当screenLeft/screenTop为null(因getTargetColAt浮点精度问题导致)时,函数直接return,没有更新 body group 的位置也没有触发重新渲染,导致视图停留在旧的位置,呈现为白色空白。setBodyAndColHeaderX/setBodyAndRowHeaderY边界校正问题: 直接取bodyGroup.lastChild作为最后一个列组使用,但虚拟滚动过程中lastChild可能是border元素(通过appendChild重新挂载到末尾),导致滚动边界校正逻辑使用了错误的列/行位置信息。修复方案:
dynamicSetX:即使screenLeft为null,仍调用setBodyAndColHeaderX更新位置并触发渲染dynamicSetY:同理,screenTop为null时仍调用updateBody并触发渲染setBodyAndColHeaderX:对lastChild增加单次if检查,跳过 border 元素取真正的列组(O(1) 操作,border 始终为最后一个子元素)setBodyAndRowHeaderY:同样对lastChild增加 border 过滤WHY 如此修复?
同时考虑到可能的性能开销问题,判断时候尽量减少while
demo截图

📝 Changelog
☑️ 自测
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough