feat(frontend): add more general hotkeys (#12138)

* add admin button hotkey

* add duplicate hotkey

* generalised hotkeys for actions

* move to fnc

* fix type checking

* more hotkeys!

* add the first primary action to the hotkeys

* small fixes

* use capital hotkeys

* add keys for navigation

* add panel navigation hotkeys

* remove admin hotkey - navigating to attachments is imo more helpful

* address conflict on macos
This commit is contained in:
Matthias Mair
2026-06-13 19:57:57 +10:00
committed by GitHub
parent e4178b1fb8
commit 457fe16f9c
10 changed files with 124 additions and 17 deletions
+13 -9
View File
@@ -17,18 +17,22 @@ export type InvenTreeHotkeyItem = [
HotkeyItemOptions?
];
export function useInvenTreeHotkeys(hotkeys: InvenTreeHotkeyItem[]) {
// Register the hotkeys using the Mantine hook
useHotkeys(
hotkeys.map(([key, _, handler, options]) => [key, handler, options])
);
// register to helper state to store hotkeys
// This allows us to display the hotkeys in the UI
const keyelems: [string, string][] = hotkeys.map(([key, description]) => [
export function useInvenTreeHotkeys(_keys: InvenTreeHotkeyItem[]) {
const keyelems: [string, string][] = _keys.map(([key, description]) => [
key,
description
]);
const mappedHotkeys: [
string,
(event: KeyboardEvent) => void,
HotkeyItemOptions?
][] = _keys.map(([key, _, handler, options]) => [key, handler, options]);
// Register the hotkeys using the Mantine hook
useHotkeys(mappedHotkeys);
// register to helper state to store hotkeys
// This allows us to display the hotkeys in the UI
useEffect(() => {
useLocalLibState.getState().addHotkeys(keyelems);
return () =>
+1
View File
@@ -17,6 +17,7 @@ export type PanelType = {
disabled?: boolean;
showHeadline?: boolean;
supportsDirty?: boolean;
hotkey?: string;
};
/**