Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save current image from the gallery view by pressing 's', 'd', or 'Enter' #6724

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions ts/components/Lightbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function Lightbox({
}, [setVideoTime, videoElement]);

const handleSave = (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
event: KeyboardEvent | React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
if (isViewOnce) {
return;
Expand Down Expand Up @@ -193,6 +193,8 @@ export function Lightbox({

const onKeyDown = useCallback(
(event: KeyboardEvent) => {
const isMacOS = (window.platform === 'darwin');

switch (event.key) {
case 'Escape': {
closeLightbox();
Expand All @@ -211,10 +213,16 @@ export function Lightbox({
onNext(event);
break;

case 's':
if (isMacOS ? event.metaKey : event.ctrlKey) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind using the isCmdOrCtrl utility function we have?

handleSave(event);
}
break;

default:
}
},
[closeLightbox, onNext, onPrevious]
[closeLightbox, onNext, onPrevious, handleSave]
);

const onClose = (event: React.MouseEvent<HTMLElement>) => {
Expand Down