Repository navigation
fix(math): 修复虚拟通道公式光标和插入位置 - #60
Merged
Merged
Conversation
There was a problem hiding this comment.
AI 代码审查(claude-opus-5-5)
改动范围清晰:选区读取与焦点恢复同时支持 Element Plus 实际渲染的 textarea,并保留 input 兼容路径。textarea ?? input 后接 querySelector('textarea, input') 兜底,即使暴露对象形态与预期不同,也能找到实际输入元素。新增的 3 项回归测试使用真实 ElInput,覆盖函数括号内聚焦、点击位置插入和选区替换,测试有效。
仅发现一处测试隔离方面的隐患,见行内意见。
由 AI 自动生成,仅供参考,不作为合并依据。审查提交:
5888183。维护者可评论/review重新审查。
There was a problem hiding this comment.
AI 代码审查(claude-opus-5-5)
改动方向正确:Element Plus 的 ElInput 在 type="textarea" 时通过 textarea 暴露真实元素,input 为空。原实现只识别 HTMLInputElement,导致读不到选区,内容只能追加到末尾,焦点也无法恢复。本次在事件目标判断、暴露属性读取和 querySelector 回退三处都加入了 HTMLTextAreaElement。新增的 3 项回归测试使用真实 ElInput,覆盖函数内光标、点击位置插入和选区替换,能直接对应本次缺陷。
以下意见无法定位到 diff 中的具体行:
- 滚动位置恢复(low,需确认):
FormulaInputCandidate只包含scrollLeft。从parsePixelValue等函数看,组件可能有按单行输入框设计的横向滚动计算或恢复逻辑,但这部分代码不在 diff 中,无法确认。若确实存在,多行 textarea 更依赖scrollTop,插入后视口可能跳动。建议检查相关逻辑在 textarea 下是否仍然适用;如有需要,同时保存并恢复scrollTop。 ??回退(无需修改):inputComponent?.textarea ?? inputComponent?.input依赖组件代理自动解包 ref。如果textarea以未解包的 ref 对象返回,即使其value为空,??也不会回退到input。不过后续的querySelector('textarea, input')仍能找到元素,目前不影响正确性。
由 AI 自动生成,仅供参考,不作为合并依据。审查提交:
f3b235a。维护者可评论/review重新审查。
mingtaojin
approved these changes
Nov 17, 2026
cuimmm
approved these changes
Nov 17, 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.
Summary
修复数学通道公式框在点击中间位置或选中文字后,按钮仍将内容追加到末尾,以及插入函数后无法在括号内继续输入的问题。选区读取与焦点恢复支持 Element Plus 实际渲染的 textarea,保留 input 兼容路径。
Evidence
After: 公式编辑器、解析和预览相关 21 项测试全部通过;修改文件 ESLint、Vue 格式检查及前端生产构建通过。
windows-huang完整 OpenTest 2.5.0 桌面应用实测 8 项通过:函数内继续输入、鼠标定位插入、键盘选区替换、分类切换与中文通道名插入、连续插入、换行编辑、真实后端保存后重开、完整页面刷新后持久化。使用独立客户端副本与运行数据,核对修复制品 SHA-256,未出现页面异常或服务器错误。Merge Danger
Door: two-way
仅修复前端输入元素访问,可直接回退,无数据迁移。
Blast Radius: editor
仅涉及数学通道公式编辑器及其组件回归测试,不修改公式计算、后端或原生接口。