From 18daf681de5e52b480b3a01695506f69b5aab252 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 4 Nov 2024 15:03:14 +0530 Subject: [PATCH] Update --- .../src/components/Sidebar/Preferences.tsx | 25 ++++++++--- .../base/components/mui/SidebarDrawer.tsx | 44 ++++++++++++++----- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsx index 9f0a5a8cf5..92e8fbc12d 100644 --- a/web/apps/photos/src/components/Sidebar/Preferences.tsx +++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx @@ -1,6 +1,7 @@ import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu"; import { NestedSidebarDrawer, + SidebarDrawer, type NestedSidebarDrawerVisibilityProps, } from "@/base/components/mui/SidebarDrawer"; import { Titlebar } from "@/base/components/Titlebar"; @@ -17,7 +18,7 @@ import { syncSettings } from "@/new/photos/services/settings"; import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem"; import ChevronRight from "@mui/icons-material/ChevronRight"; import ScienceIcon from "@mui/icons-material/Science"; -import { Box, Stack } from "@mui/material"; +import { Box, DialogProps, Stack } from "@mui/material"; import DropdownInput from "components/DropdownInput"; import { t } from "i18next"; import React, { useEffect } from "react"; @@ -47,10 +48,24 @@ export const Preferences: React.FC = ({ onRootClose(); }; + const handleDrawerClose: DialogProps["onClose"] = (_, reason) => { + console.log(reason); + if (reason === "backdropClick") { + handleRootClose(); + } else { + onClose(); + } + }; + return ( - = ({ {...mlSettingsVisibilityProps} onRootClose={handleRootClose} /> - + ); }; diff --git a/web/packages/base/components/mui/SidebarDrawer.tsx b/web/packages/base/components/mui/SidebarDrawer.tsx index 8ed8d53b2e..2f9bf86a7b 100644 --- a/web/packages/base/components/mui/SidebarDrawer.tsx +++ b/web/packages/base/components/mui/SidebarDrawer.tsx @@ -39,16 +39,38 @@ export type NestedSidebarDrawerVisibilityProps = ModalVisibilityProps & { */ export const NestedSidebarDrawer: React.FC< NestedSidebarDrawerVisibilityProps & DrawerProps -> = (props) => ( +> = ({ onClose, onRootClose, ...rest }) => { + // Intercept backdrop taps and repurpose them to close the entire stack. + const handleClose: DrawerProps["onClose"] = (_, reason) => { + if (reason == "backdropClick") { + onClose(); + onRootClose(); + } else { + onClose(); + } + }; + // MUI doesn't (currently, AFAIK) have support for nested drawers, so we // emulate that by showing a drawer atop another. To make it fit, we need to - // modify a few knobs: - // - // 1. Disable the transition (otherwise our nested drawer visibly slides in - // from the wrong direction). - // - // 2. Disable the backdrop (otherwise we'd end up with two of them - one - // from the original drawer, and one from this nested one). - // - -); + // modify a few knobs. + + return ( + + ); +};