Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix using arrow keys to move in input field causes photo-viewer file change

Abhinav57b3e4461ffd
diff --git a/apps/photos/src/components/PhotoViewer/index.tsx b/apps/photos/src/components/PhotoViewer/index.tsx
index 0aa4f31972..d421ba6546 100644
--- a/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/apps/photos/src/components/PhotoViewer/index.tsx
@@ -192,6 +192,12 @@ function PhotoViewer(props: Iprops) {
case 'L':
onFavClick(photoSwipe?.currItem as EnteFile);
break;
+ case 'ArrowLeft':
+ handleArrowClick(event, 'left');
+ break;
+ case 'ArrowRight':
+ handleArrowClick(event, 'right');
+ break;
default:
break;
}
@@ -352,6 +358,7 @@ function PhotoViewer(props: Iprops) {
maxSpreadZoom: 5,
index: currentIndex,
showHideOpacity: true,
+ arrowKeys: false,
getDoubleTapZoom(isMouseClick, item) {
if (isMouseClick) {
return 2.5;
@@ -505,6 +512,24 @@ function PhotoViewer(props: Iprops) {
appContext.setDialogMessage(getTrashFileMessage(() => trashFile(file)));
};
+ const handleArrowClick = (
+ e: KeyboardEvent,
+ direction: 'left' | 'right'
+ ) => {
+ // ignore ctrl/cmd + a if the user is typing in a text field
+ if (
+ e.target instanceof HTMLInputElement ||
+ e.target instanceof HTMLTextAreaElement
+ ) {
+ return;
+ }
+ if (direction === 'left') {
+ photoSwipe.prev();
+ } else {
+ photoSwipe.next();
+ }
+ };
+
const updateItems = (items: EnteFile[]) => {
try {
if (photoSwipe) {