fix: preserve reverse tab navigation - #267
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. Walkthrough下拉菜单现在会在按下 Shift+Tab 时关闭,并将焦点返回触发按钮。新增测试验证菜单状态、焦点位置和默认事件行为。普通 Tab 行为保持不变。 Changes下拉菜单键盘交互
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change preserves forward Tab behavior while allowing Shift+Tab to close the dropdown and continue normal reverse focus navigation. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary\n\n- close an open dropdown when the user presses Shift+Tab\n- leave the event uncancelled so the browser can continue reverse focus navigation\n- retain the existing forward Tab behavior that moves focus into the overlay\n- add a regression covering focus, visibility, and default-prevention behavior\n\n## Problem\n\nThe global Tab handler currently calls focusMenu() whenever the overlay has not yet received focus. It does this for both Tab and Shift+Tab. As a result, Shift+Tab from the trigger is prevented and focus is forced forward into the menu instead of allowing the user to move to the previous control.\n\n## Validation\n\n- exact-base causal probe: the new regression fails because defaultPrevented is true and focusMenu() runs\n- fixed head: forward Tab and Shift+Tab keyboard tests pass\n- all 20 non-snapshot basic tests pass\n- point and props suites pass (2 tests)\n- npm run tsc\n- npm run compile (ESM, CommonJS, and declarations)\n- focused ESLint, Prettier, and git diff --check\n\nWith the currently resolved dependency tree, the untouched simply works snapshot expects old rc-menu generated ids while rc-menu now emits rc-menu-uuid-test-id-*; that same unrelated snapshot drift was present before the product-code fix and was not modified here.\n\nAI assistance disclosure: Codex was used to trace the focus handler, construct the red/green regression, audit open-PR overlap, run validation, and draft this description. I verified the event cancellation, focus target, menu state, exact diff, and test results directly.
Summary by CodeRabbit
Bug Fixes
Tests