Repository navigation
fix(vchart): preserve manual resize with autoFit enabled - #4711
Merged
Merged
Conversation
skie1997
reviewed
Oct 16, 2026
skie1997
left a comment
Contributor
There was a problem hiding this comment.
已审查 a741d11,本轮未发现需要修改的确定性代码缺陷。
重点核对了 _lastAutoSize 与 _currentSize 的初始化、自动通知、手动 resize、updateSpec 重建及显式尺寸更新:自动通知按来源快照去重,真实来源变化仍更新当前尺寸;来源尺寸恰好等于当前画布时,也会推进自动快照。没有新增包依赖。
独立验证:将该提交源码导出到临时目录,复跑 resize-remake.test.ts、update-spec.test.ts、vchart.test.ts,3 个套件、75 项测试全部通过。没有修改 PR 代码;本轮未重跑全量视觉测试。PR 记录的新增视觉用例在旧基线失败,与所修复的回归一致,但不等于完整视觉对照通过。
CI 提醒:size (18.x) 仍失败,日志为产物 2.42 MB 超过 2 MB 门槛(超出 422.57 kB)。目前没有证据将这一总量超限归因于本次改动,故不作为本 PR 引入的代码缺陷,但合并前仍应确认该检查的处理方式。
skie1997
approved these changes
Oct 16, 2026
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.
默认
autoFit下,在显式 600×600 的图表renderAsync()后立即调用resize(300, 300),首次ResizeObserver通知会把画布恢复到 600×600。本 PR 让未变化的自动尺寸来源保留手动 resize 的结果,同时继续响应真实容器变化,并保留 updateSpec 重建后的当前尺寸。🤔 这个分支是...
🔗 相关的 PR 链接
修复 #4705 中
77d33b1e783aba6776c8cc04879687b35e190c3c引入的回归。💡 问题的背景&解决方案
_currentSize原本用于自动尺寸变化检测,原修复又让手动 resize 修改它。自动监听随后从未变化的 spec 计算出 600×600,和已更新的 300×300 缓存比较,便错误触发反向 resize。新增
_lastAutoSize保存上次自动计算的尺寸,_currentSize保留当前画布尺寸;手动 resize 仅更新后者。初始化、自动尺寸变化和新 spec 尺寸更新时同步自动快照。尺寸对象改为只读快照并整体替换,避免两个快照共享引用时被原地修改。补充四项默认 autoFit 单元回归,以及
api/resize-auto-fit浏览器用例。浏览器用例在同一任务内 renderAsync 后立即 resize,并用真实 ResizeObserver 交付屏障验证首次通知、未变化的窗口事件和 chart 重建后尺寸均为 300×300。🧪 验证
resize-remake.test.ts、update-spec.test.ts、vchart.test.ts。提交钩子的 ESLint、Prettier、commitlint 均通过;推送钩子的rush test --only tag:package完成,其中 VChart 全量 94 个测试套件、530 项测试通过。node packages/vchart/scripts/visual-test.mjs,选中 264/264。官方 develop 基线f017af88fe54b113e95a207d8f3d79624cb0f96f的 263 个既有用例通过;新增resize-auto-fit复现旧缺陷,尺寸从 300×300 恢复为 600×600,触发INTERACTION_ASSERTION_FAILED。工具因此中止后续 current 阶段,完整基线比较状态为 error,不能记为通过。📝 Changelog
☑️ 自测
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough