Repository navigation
fix(Menu): 在异步焦点处理中保留事件目标 - #2930
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe focus handler now captures the focused menu item before asynchronous processing. Tests verify that submenu pointer movement preserves the open state and that mounted test wrappers and timers are cleaned up. ChangesMenu focus stability
Priority: ➖ Normal — Schedule the menu focus fix because it resolves a medium-severity submenu bug that can cause unexpected closing and flicker during pointer movement. Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change prevents an open submenu from closing while the pointer continues moving within its trigger, with regression coverage for the affected interaction. No merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔗 关联 issue
Closes #2929
❓ 变更类型
📚 说明
子菜单通过悬停打开后,继续在同一个触发项内移动鼠标,可以使它意外关闭。
MenuItemImpl在 pointermove 内调用.focus();异步 focus 处理器恢复时再读取event.currentTarget,在此路径中会得到 null,并覆盖当前高亮项。本次在
await nextTick()前保存该元素,随后使用保存的目标更新高亮。保留原有的异步处理、defaultPrevented和disabled判断;生产代码仅修改这一处处理器。新增回归测试复用现有 MenuWithSubmenu fixture,覆盖「悬停打开 → 再次在同一触发项内 pointermove → 子菜单保持打开」。该断言在未修复的上游代码上失败,修复后通过。
同时为 Menu 子菜单测试和 DropdownMenuFilter 测试补齐组件卸载。Filter 测试原先仅清空 body,没有卸载组件,导致共享的键盘输入状态跨测试残留:受影响用例单独运行通过,连续运行失败。补齐卸载后,原有断言均通过,没有修改 Filter 的生产逻辑或测试预期。
验证
pnpm --filter reka-ui exec vitest run --coverage --maxWorkers=4:97 个测试文件、2042 项测试通过。pnpm --filter reka-ui build:类型检查和构建通过。pnpm --filter reka-ui size:包体积检查通过。git diff --check:通过。独立复现和环境详情见关联 issue。本次未验证其他浏览器。
📝 Checklist
Summary by CodeRabbit
Bug Fixes
Tests