Skip to content

fix(vue-vtable): resolve DOM component flickering during column resize (#5038)#5100

Open
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Erica-cod:fix/vue-dom-flicker-resize-5038
Open

fix(vue-vtable): resolve DOM component flickering during column resize (#5038)#5100
Erica-cod wants to merge 1 commit intoVisActor:developfrom
Erica-cod:fix/vue-dom-flicker-resize-5038

Conversation

@Erica-cod
Copy link
Copy Markdown
Contributor

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

🤔 这个分支是...

  • Bug fix

🔗 相关 issue 连接

fix #5038

💡 问题的背景&解决方案

问题: 使用 Vue DOM 组件(如 ArcoDesign Tag、Comment)渲染单元格内容时,拖动调整列宽会导致 DOM 内容严重闪烁。

根因: 列宽拖拽的每一帧,核心层都会对 custom container 执行销毁+重建,新的 scene graph graphic 拥有新的 _uid。Vue 插件的 renderGraphicHTML 是异步的(rAF 延迟到下一帧),但 clearCacheContainer 是同步的(当帧立即执行)。_uid 变化导致缓存 key 失效,旧 DOM 被清除而新 DOM 要等下一帧才创建,每帧至少 1 帧 DOM 空白期。React 不受影响是因为它的 renderGraphicHTML 是同步的。

调研后决定不改核心层: 在核心层跳过 removeChild+dealWithCustom 影响范围太大(React/Vue/Canvas 三种 customLayout 全受影响),且跳过 dealWithCustom 意味着 customLayout 函数不会以新宽度重新执行,对纯 Canvas 布局可能产生错误。闪烁的可见症状完全由 Vue 插件异步渲染+不稳定缓存 key 导致,只改 Vue 侧即可消除。

修复方案(仅改 vue-vtable 包):

  1. customLayoutUtils.ts: 在 createCustomLayout 中为 vue Group 注入 cell_col_row_index 格式的稳定 ID,确保场景图重建后缓存 key 不变
  2. vtable-vue-attribute-plugin.ts: renderGraphicHTML 检测到缓存命中时同步调用 doRenderGraphic(跳过 rAF),让 renderId 在 clearCacheContainer 执行前完成更新;缓存命中且 DOM 在文档中时跳过 Vue.render(),仅更新 CSS 样式;同时更新 targetMap.graphic 引用指向新节点

📝 Changelog

Language Changelog
🇺🇸 English Fix Vue DOM component flickering during column resize
🇨🇳 Chinese 修复 Vue DOM 组件在列宽拖拽时的闪烁问题

☑️ 自测

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

VisActor#5038)

Inject stable cache IDs in customLayoutUtils.

Sync render on cache hit to prevent clearCacheContainer race.

Made-with: Cursor
@Erica-cod
Copy link
Copy Markdown
Contributor Author

修复效果:
Uploading 20260407_220642.mp4…

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] 单元格渲染DOM组件,调整列宽时内容闪烁严重

1 participant