Replies: 2 comments
|
The more I think about it a better approach would probably be an option to temporarily reset all current hotkey registrations. One use-case would be this:
This becomes cumbersome to manage as Component A suddenly has to track if any other relevant component is rendered. A solution could be:
// Component A
useHotkey('Mod+A', callbackA, { persistent: false )
// Component B
useResetHotkeys()
useHotkey('Mod+A', callbackB, { persistent: false )
// rudimentary useDeactivateHotkeys composable
const useDeactivateHotkeys = () => {
const mgr = getHotkeyManager()
// temporarily deactivate or create
// backup of all current registrations
// if they are not marked as "persistent"
mgr.deactivateCurrentRegistrations()
onUnmounted(() => {
mgr.reactivateRegistrations()
})
}One edge-case to handle would be certain hotkeys which may need to be persistent except in a few cases, e.g. a global search dialog. For this case a boolean argument may be needed: const forceDeactivation = true
mgr.deactivateCurrentRegistrations(forceDeactivation) |
0 replies
|
I am closing this discussion, as scoped hotkey targets are better suited to handle this. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When dealing with certain hotkeys, which essentially do the same just in different contexts, it becomes difficult to manage which should have priority.
Example: opening a modal from different contexts or components, where the hotkey callbacks differ slightly. This currently forces a tight coupling between components where one needs to know the current active state of the other.
I am unsure if this idea goes against conventions, but it could be nice to have an
overrideoption as conflict behavior, i.e. temporarily disabling all previous hotkey registrations.All reactions