feat: "add to album" shortcut and generic menu option shortcuts (#15056)

* Add shortcut prop to MenuOption

* Add "add to album" shortcut in photo grid
This commit is contained in:
David Koňařík
2025-01-07 17:29:22 +01:00
committed by GitHub
parent c148a28a82
commit fa0b352bd0
3 changed files with 45 additions and 2 deletions
+20
View File
@@ -16,6 +16,26 @@ export type ShortcutOptions<T = HTMLElement> = {
preventDefault?: boolean;
};
export const shortcutLabel = (shortcut: Shortcut) => {
let label = '';
if (shortcut.ctrl) {
label += 'Ctrl ';
}
if (shortcut.alt) {
label += 'Alt ';
}
if (shortcut.meta) {
label += 'Cmd ';
}
if (shortcut.shift) {
label += '⇧';
}
label += shortcut.key.toUpperCase();
return label;
};
/** Determines whether an event should be ignored. The event will be ignored if:
* - The element dispatching the event is not the same as the element which the event listener is attached to
* - The element dispatching the event is an input field