Option to open the comment box directly on keyboard activation (activationAction)
Summary
There is no supported way to make keyboard activation open the comment (prompt mode) box directly. Activating with the hotkey and clicking an element always runs the copy action, so getting to the comment box takes an extra trip through the context menu (or pressing Enter after selecting). It would be great to configure the action that runs when an element is selected after keyboard activation.
Current behavior (react-grab 0.2.0)
- The toolbar has a persisted
defaultAction(copy|comment), and clicking the toolbar button honors it. - Keyboard activation (
activationKey/activationMode) ignoresdefaultAction: the element-select handler goes straight to the copy flow unless a pending-comment flag is set. - The only public way to set that flag is the
comment()API, which is a toggle.
What I would like
Something like:
init({
activationKey: "Alt",
activationMode: "hold",
activationAction: "comment", // "copy" | "comment" | <action id>, default "copy"
})Or simply have keyboard activation honor the toolbar's defaultAction, since that is what the user already picked in the UI. Either way the target flow is: hold the modifier, click an element, and the comment box opens immediately.
Workaround I am using
import { getGlobalApi, registerPlugin } from "react-grab"
getGlobalApi()?.setOptions({ activationKey: "Alt", activationMode: "hold" })
registerPlugin({
name: "comment-on-activate",
hooks: {
onActivate: () => {
getGlobalApi()?.comment()
},
},
})This works (the box opens on click and stays open after the key is released), but it leans on comment() being a toggle: if onActivate ever fires twice per activation, or another plugin also calls comment(), the two calls cancel out. A first-class option would avoid that.
Environment
- react-grab 0.2.0
- TanStack Start on Vite 8, React 19
- macOS, Chrome
Source: aidenybai/react-grab