Add keyboard shortcuts for gizmo menu#591
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThe PR refactors the area overlay controller, renaming Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 37 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
main/accessibility.js (1)
226-232: ⚡ Quick winOnly close the overlay after a successful activatable target is found.
Right now, a disabled/unavailable button still dismisses the menu. Keep the overlay open unless activation can actually occur.
Suggested refactor
activateButton(entry) { - this.toggle(false); const el = document.getElementById(entry.id); - if (!el) return; + if (!el || el.disabled || el.offsetParent === null) return; + this.toggle(false); el.focus(); - if (!el.disabled) el.click(); + el.click(); },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@main/accessibility.js` around lines 226 - 232, In activateButton, don't call this.toggle(false) until you've confirmed an activatable element was found and activation succeeded: move the this.toggle(false) call to after verifying const el = document.getElementById(entry.id) exists and is not disabled, then focus and click it and only then call this.toggle(false); if el is missing or el.disabled is true, do not dismiss the overlay (return early). Reference: activateButton, this.toggle, entry.id, el.disabled, el.focus, el.click.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@main/accessibility.js`:
- Around line 178-184: The focus check only inspects document.activeElement
within `#gizmoButtons`; instead also detect whether a gizmo is currently active
and skip focusing when one is active. Modify the logic around the existing gizmo
focus block (references: `#gizmoButtons` and getElementById("showShapesButton"))
to add a guard like checking a known active-gizmo signal (for example a global
state variable such as window.activeGizmo, an element with a class like
.gizmo-active, or a data attribute e.g. [data-gizmo-active="true"]) and treat
that as equivalent to alreadyFocused; only call btn.focus() when neither an
element inside `#gizmoButtons` is focused nor any active-gizmo indicator exists.
Ensure the new check is used wherever Ctrl+G focus behavior is handled so active
gizmo usage preserves focus.
---
Nitpick comments:
In `@main/accessibility.js`:
- Around line 226-232: In activateButton, don't call this.toggle(false) until
you've confirmed an activatable element was found and activation succeeded: move
the this.toggle(false) call to after verifying const el =
document.getElementById(entry.id) exists and is not disabled, then focus and
click it and only then call this.toggle(false); if el is missing or el.disabled
is true, do not dismiss the overlay (return early). Reference: activateButton,
this.toggle, entry.id, el.disabled, el.focus, el.click.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 64ff4233-3171-468c-ba6f-0f7a7bb3f498
📒 Files selected for processing (2)
main/accessibility.jsstyle.css
Summary
When the gizmo menu is activated with Ctrl + G, shortcut keys 1-9 appear below each gizmo. You can press the number key to activate the gizmo while this overlay is active.
AI usage
This was mostly a reimplementation of the area overlay (which I have renamed for clarity) but with different styles. Claude Sonnet 4.6 helped me find out why tab was initially not functioning, because I'd forgotten to remove some of the AreaOverlay functionality for tabs which wasn't needed for this overlay.
Summary by CodeRabbit
New Features
Style