Repository navigation
fix: consume Escape when returning from a submenu - #899
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough子菜单收到 Escape 时,现在会停止事件传播。子菜单仍会关闭,焦点仍会返回父菜单项。根菜单项上的 Escape 事件仍会传播至 Changes子菜单 Escape 处理
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Possibly related issues
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #899 +/- ##
=======================================
Coverage 99.72% 99.72%
=======================================
Files 26 26
Lines 736 738 +2
Branches 204 205 +1
=======================================
+ Hits 734 736 +2
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| const onOpenChange = jest.fn(); | ||
| const onWindowKeyDown = jest.fn(); | ||
| window.addEventListener('keydown', onWindowKeyDown); | ||
| const { container, getByText, unmount } = render( |
Problem and behavior
When an item in a popup submenu has focus, Escape already closes that submenu and focuses its parent item, but the event continues to window-level popup listeners. A surrounding Dropdown then closes too. Consume Escape only when a real parent menuitem was found. Escape at the root remains available to the surrounding popup; inline behavior is unchanged.
Refs react-component/dropdown#274. This complements #893 (Escape on the root container); it does not copy or replace that patch or #898's focus changes.
Validation
npm test -- --runInBand --no-cache: 13 suites, 146 tests, 20 snapshots passed.8dfdef453a24cee1bda115e3249b17289356829d, both regressions fail (10 existing keyboard tests pass).The companion react-component/dropdown#275 lets nested menu Escape reach this handler when react-component/dropdown#273 uses a window capture listener; the current bubble-listener Dropdown works with this Menu fix alone. Native bundles use the same dependency tree/React instance with source controls; this is not release integration or a screen-reader conformance claim.
AI assistance disclosure: Codex assisted tracing, implementation, regression tests and browser verification; the reported tests and real key-input results were executed locally.
Summary by CodeRabbit