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:
Gabriel Gordon-Hall
2025-09-30 11:40:34 +01:00
committed by GitHub
parent 23243dda7a
commit 6727e2dbb9
7 changed files with 420 additions and 202 deletions

View File

@@ -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
);
}