feat: keyboard shortcuts for approvals (#869)
* wip * cmd click shortcut to deny approval * cleaner type * show percentage in progress bar * improve structure of PendingApprovalComponent * enter to approve request * disable kanban scope * fix approval scope selection
This commit is contained in:
committed by
GitHub
parent
23243dda7a
commit
6727e2dbb9
@@ -4,9 +4,11 @@ import {
|
||||
useKeyboardShortcutsRegistry,
|
||||
type ShortcutConfig,
|
||||
} from '@/contexts/keyboard-shortcuts-context';
|
||||
import type { EnableOnFormTags } from '@/keyboard/types';
|
||||
|
||||
export interface KeyboardShortcutOptions {
|
||||
enableOnContentEditable?: boolean;
|
||||
enableOnFormTags?: EnableOnFormTags;
|
||||
preventDefault?: boolean;
|
||||
}
|
||||
|
||||
@@ -18,7 +20,11 @@ export function useKeyboardShortcut(
|
||||
const unregisterRef = useRef<(() => void) | null>(null);
|
||||
|
||||
const { keys, callback, when = true, description, group, scope } = config;
|
||||
const { enableOnContentEditable = false, preventDefault = false } = options;
|
||||
const {
|
||||
enableOnContentEditable = false,
|
||||
enableOnFormTags,
|
||||
preventDefault = false,
|
||||
} = options;
|
||||
|
||||
// Keep latest callback/when without forcing re-register
|
||||
const callbackRef = useRef(callback);
|
||||
@@ -64,9 +70,10 @@ export function useKeyboardShortcut(
|
||||
{
|
||||
enabled: true, // we gate inside handler via whenRef
|
||||
enableOnContentEditable,
|
||||
enableOnFormTags,
|
||||
preventDefault,
|
||||
scopes: scope ? [scope] : ['*'],
|
||||
},
|
||||
[keys, scope] // handler uses refs; only rebinding when identity changes
|
||||
[keys, scope, enableOnContentEditable, enableOnFormTags, preventDefault] // handler uses refs; only rebinding when identity changes
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user