π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(FileContextMenu):hide-SelectedFileOptions-when-context-menu-shown
Aswin Asoke70f83c1bb99
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex 3ccb87401b..00182f5ac6 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -276,6 +276,10 @@ export interface FileListProps {* Whether to show the "Edit Location" action in the context menu.*/showEditLocationAction?: boolean;+ /**+ * Called when the context menu opens or closes.+ */+ onContextMenuOpenChange?: (open: boolean) => void;}/**@@ -306,6 +310,7 @@ export const FileList: React.FC<FileListProps> = ({onContextMenuAction,showAddPersonAction,showEditLocationAction,+ onContextMenuOpenChange,}) => {const [_items, setItems] = useState<FileListItem[]>([]);const items = useDeferredValue(_items);@@ -329,6 +334,7 @@ export const FileList: React.FC<FileListProps> = ({file: EnteFile;fileIndex: number;} | null>(null);+ const isContextMenuOpen = contextMenu !== null;// Track selection state before right-click modified it.// If there are already 3 files explicitly selected via checkmarks,@@ -703,9 +709,11 @@ export const FileList: React.FC<FileListProps> = ({file,fileIndex,});+ onContextMenuOpenChange?.(true);},[onContextMenuAction,+ onContextMenuOpenChange,selected,setSelected,user,@@ -730,7 +738,8 @@ export const FileList: React.FC<FileListProps> = ({});setContextMenu(null);- }, [setSelected]);+ onContextMenuOpenChange?.(false);+ }, [onContextMenuOpenChange, setSelected]);const handleContextMenuActionWithTracking = useCallback((action: FileContextAction) => {@@ -743,13 +752,14 @@ export const FileList: React.FC<FileListProps> = ({const renderListItem = useCallback((item: FileListItem, isScrolling: boolean) => {const haveSelection = selected.count > 0;+ const showGroupCheckbox = haveSelection && !isContextMenuOpen;switch (item.type) {case "date":return intersperseWithGaps(item.groups,({ date, dateSpan }) => [<DateListItem key={date} span={dateSpan}>- {haveSelection && (+ {showGroupCheckbox && (<Checkboxkey={date}name={date}@@ -853,6 +863,7 @@ export const FileList: React.FC<FileListProps> = ({handleRangeSelect,handleSelect,hoverIndex,+ isContextMenuOpen,isShiftKeyPressed,mode,onChangeSelectAllCheckBox,@@ -982,7 +993,6 @@ export const FileList: React.FC<FileListProps> = ({onClose={handleContextMenuClose}actions={contextMenuActions}onAction={handleContextMenuActionWithTracking}- selectedCount={selected.count}/>)}</Box>diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex 4bf45fe022..7faaeb076e 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -109,6 +109,7 @@ export type FileListWithViewerProps = {| "emailByUserID"| "listBorderRadius"| "onContextMenuAction"+ | "onContextMenuOpenChange"| "showAddPersonAction"| "showEditLocationAction"> &@@ -161,6 +162,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({emailByUserID,listBorderRadius,onContextMenuAction,+ onContextMenuOpenChange,showAddPersonAction,showEditLocationAction,isInIncomingSharedCollection,@@ -358,6 +360,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({onVisibleDateChange,collectionSummary: activeCollectionSummary,onContextMenuAction,+ onContextMenuOpenChange,showAddPersonAction,showEditLocationAction,}}diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 5b2e45b0fb..dd06e23e59 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -193,6 +193,7 @@ const Page: React.FC = () => {[],);const [isFileViewerOpen, setIsFileViewerOpen] = useState(false);+ const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);// Pending navigation from feed item clickconst [pendingFileNavigation, setPendingFileNavigation] = useState<{@@ -1517,7 +1518,9 @@ const Page: React.FC = () => {);const showSelectionBar =- selected.count > 0 && selected.collectionID === activeCollectionID;+ selected.count > 0 &&+ selected.collectionID === activeCollectionID &&+ !isContextMenuOpen;if (!user) {// Don't render until we dispatch "mount" with the logged in user.@@ -1740,6 +1743,7 @@ const Page: React.FC = () => {)}isInHiddenSection={barMode == "hidden-albums"}onContextMenuAction={handleContextMenuAction}+ onContextMenuOpenChange={setIsContextMenuOpen}showAddPersonAction={showAddPersonAction}showEditLocationAction={selected.ownCount > 0}{...{diff --git a/web/packages/new/photos/components/FileContextMenu.tsx b/web/packages/new/photos/components/FileContextMenu.tsxindex 31cc8722e2..8aa0f736e8 100644--- a/web/packages/new/photos/components/FileContextMenu.tsx+++ b/web/packages/new/photos/components/FileContextMenu.tsx@@ -13,12 +13,10 @@ import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlinedimport VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";import type { SvgIconProps } from "@mui/material";import {- Box,ListItemIcon,ListItemText,Menu,MenuItem,- Typography,styled,} from "@mui/material";import { StarBorderIcon } from "ente-new/photos/components/icons/StarIcon";@@ -46,7 +44,6 @@ interface FileContextMenuProps {/** Callback when an action is selected. */onAction: (action: FileContextAction) => void;/** Number of files currently selected. */- selectedCount: number;}interface ActionConfig {@@ -86,7 +83,7 @@ const actionConfigs: Record<FileContextAction, ActionConfig> = {* thumbnail.*/export const FileContextMenu: React.FC<FileContextMenuProps> = memo(- ({ open, anchorPosition, onClose, actions, onAction, selectedCount }) => {+ ({ open, anchorPosition, onClose, actions, onAction }) => {const handleActionClick = useCallback((action: FileContextAction) => {onClose();@@ -152,20 +149,6 @@ export const FileContextMenu: React.FC<FileContextMenuProps> = memo(</StyledMenuItem>);})}- {selectedCount > 1 && (- <Box sx={{ px: 2, pt: 0, pb: 0.5 }}>- <Typography- variant="small"- sx={{- color: "text.faint",- fontSize: "0.65rem",- opacity: 0.7,- }}- >- {t("selected_count", { selected: selectedCount })}- </Typography>- </Box>- )}</StyledMenu>);},