You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: consume Escape when returning from a submenu - #899
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.
Two new regression cases cover one and two submenu levels, parent-item focus, open keys, and root Escape propagation. With only the hook restored to base 8dfdef453a24cee1bda115e3249b17289356829d, both regressions fail (10 existing keyboard tests pass).
TypeScript, compile, and lint pass; lint reports 0 errors / 11 existing warnings. Existing isolated dependency tree reused, Node 24.15.0.
Actual Chrome click → Tab → ArrowRight → Child → Escape: submenu closes, parent Dropdown remains open, focus returns to Submenu. The unmodified control closes the parent Dropdown. Also verified three-level unwind with the companion Dropdown guard plus build(deps): update ismobilejs requirement from ^0.5.1 to ^1.0.2 #273's capture-phase change, and root Escape still closes and returns trigger focus.
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.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 4975b03a-43db-4e36-9383-a378194ae707
📥 Commits
Reviewing files that changed from the base of the PR and between 8dfdef4 and e00e0c2.
📒 Files selected for processing: 2
src/hooks/useAccessibility.ts
tests/Keyboard.spec.tsx
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The submenu Escape change has no identified merge-blocking issue; it is ready for normal merge checks.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
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 2 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
标题“fix: consume Escape when returning from a submenu”准确概括了主要变更:从子菜单返回时消费 Escape 事件,避免事件继续传播到外部 Dropdown。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
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
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.
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