🚸 Add select all keyboard shortcut for groups

This commit is contained in:
Baptiste Arnaud 2025-01-31 10:15:46 +01:00
parent 30a045ef2a
commit 51fbb26777
No known key found for this signature in database
2 changed files with 13 additions and 0 deletions

View File

@ -127,6 +127,9 @@ export const GroupSelectionMenu = ({
},
backspace: handleDelete,
paste: handlePaste,
selectAll: () => {
setFocusedGroups(typebot?.groups.map((g) => g.id) ?? []);
},
});
return (

View File

@ -12,6 +12,7 @@ type Props = {
cut?: () => void;
duplicate?: () => void;
backspace?: () => void;
selectAll?: () => void;
};
export const useKeyboardShortcuts = ({
@ -22,6 +23,7 @@ export const useKeyboardShortcuts = ({
cut,
duplicate,
backspace,
selectAll,
}: Props) => {
const isUndoShortcut = (event: KeyboardEvent) =>
(event.metaKey || event.ctrlKey) && event.key === "z" && !event.shiftKey;
@ -41,6 +43,9 @@ export const useKeyboardShortcuts = ({
const isDuplicateShortcut = (event: KeyboardEvent) =>
(event.metaKey || event.ctrlKey) && event.key === "d";
const isSelectAllShortcut = (event: KeyboardEvent) =>
(event.metaKey || event.ctrlKey) && event.key === "a";
const isBackspaceShortcut = (event: KeyboardEvent) =>
event.key === "Backspace";
@ -95,5 +100,10 @@ export const useKeyboardShortcuts = ({
backspace();
return;
}
if (selectAll && isSelectAllShortcut(event)) {
event.preventDefault();
selectAll();
return;
}
});
};