feat: add keyboard shortcut (Alt+Shift+C) to toggle Component Inspector#1090
feat: add keyboard shortcut (Alt+Shift+C) to toggle Component Inspector#1090JamesGoslings wants to merge 1 commit intovuejs:mainfrom
Conversation
✅ Deploy Preview for vue-devtools-docs canceled.
|
skirtles-code
left a comment
There was a problem hiding this comment.
This seems to work well for me.
A few thoughts...
There's a similar (but different) feature request in #495. While it is separate to the feature being requested here, I do think it's worth considering in the context of how we'd like keyboard shortcuts to work more generally.
In particular, it's not clear to me that all keyboard shortcuts should be listed in the console when starting Vite.
I wonder whether it might be better to add the shortcuts to the button tooltips instead?
What's the reason for the e.preventDefault() calls in the two listeners? Are they precautionary or is there something specific they're intended to prevent?
Personally, I'd remove the code comments. I think the code is clear enough without them.
Closes vuejs#1058 - Add Alt(Option)+Shift+C shortcut in overlay to toggle Component Inspector - Add the same shortcut in client (DevTools iframe) via RPC - Show the shortcut in the button tooltips
9bea558 to
465bcd2
Compare
|
@skirtles-code Thanks for the review! I've pushed an update addressing your feedback.
Good point. I've removed the console output and added the shortcut hint to the button tooltips instead. For consistency, I also added
They were precautionary —
Removed. Agreed the code is self-explanatory.
Agreed. A unified, possibly user-configurable shortcut system would be valuable (the original issue also asked for customization). Happy to work on it in a follow-up once the overall direction is decided. This PR focuses on the minimal change for #1058. |
Description
Closes #1058
This PR adds a keyboard shortcut
Alt(Option)+Shift+Cto toggle the Component Inspector, solving the pain point where clicking to activate the inspector causes pop-ups/overlays to close.Motivation
Many UI libraries auto-close pop-ups on outside click. When using the Component Inspector to locate components inside these pop-ups, clicking activates the inspector but simultaneously closes the pop-up. A keyboard shortcut avoids this issue entirely.
Changes
packages/overlay/src/App.vueAlt+Shift+Ckeydown listener to calltoggleVueInspector()packages/client/src/App.vuepackages/vite/src/vite.tsHow it works
Alt+Shift+D(toggle DevTools panel)Altmaps toOptionon macOS automatically (viae.altKey)vueInspectorSupported/vueInspectorDetectedis trueEscapestill works to exit the inspector (unchanged)Terminal output
Test
Note
The issue author also mentioned customizable shortcuts. Since all existing shortcuts in the project (
Alt+Shift+D,Escape) are hardcoded, adding customization would require architectural changes (e.g. passing user config through virtual modules to runtime). This can be addressed in a follow-up PR if needed.