fix(vue): ensure onFocus/onBlur/onAssetUpload callbacks use latest reference#125
Open
zhiyun22 wants to merge 1 commit into
Open
fix(vue): ensure onFocus/onBlur/onAssetUpload callbacks use latest reference#125zhiyun22 wants to merge 1 commit into
zhiyun22 wants to merge 1 commit into
Conversation
|
|
f919e4b to
615904c
Compare
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.
Summary / 摘要
修复 Vue 包中 onFocus、onBlur、onAssetUpload 回调引用过时的问题,确保回调在配置变化后始终调用最新版本。
Motivation / 背景与动机
fix-vue-callback-staleness问题描述
packages/vue的useEditor中,onChange回调通过闭包 +resolveConfig()动态获取最新引用,行为正确;但onFocus、onBlur、onAssetUpload通过...rest直接传给createEditor,在编辑器创建时被固定引用。当配置是响应式的(computed / getter)且回调引用变化时,这些回调仍使用创建时的旧版本,可能导致:Changes / 变更内容
packages/vue:buildCreateConfig移入useEditor作用域,为onFocus、onBlur、onAssetUpload创建包装函数,每次调用时通过resolveConfig()获取最新回调Testing / 测试
pnpm testpasses / 全绿pnpm build) / 受影响包构建通过calls the latest onFocus after config updatescalls the latest onBlur after config updatescalls the latest onAssetUpload after config updates测试命令
结果:18 tests passed(原有 15 个 + 新增 3 个)
Compliance / 合规自检
AI-assisted notes / AI 使用说明:
AI-assisted code review and test case generation
无新增依赖
dist/,dist-electron/, compiled.jsfrom.ts) / 未提交构建产物.env/ personal vault data committed / 无敏感信息Checklist / 自检清单
live-preview-table.ts→ walked through the 12 Table Widget rules in CLAUDE.md / 已核对 12 条表格规则(未涉及)Screenshots / Recordings · 截图或录屏 (UI changes)