Skip to content

armgit / ente

Public Imported from GitHub
0

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

S3

Manav Rathid9e106088a6f
diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsx
index 0466109c2a..92e8fbc12d 100644
--- a/web/apps/photos/src/components/Sidebar/Preferences.tsx
+++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx
@@ -1,10 +1,11 @@
import { MenuItemGroup, MenuSectionTitle } from "@/base/components/Menu";
-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";
-import { Titlebar } from "@/base/components/Titlebar";
import {
- useModalVisibility,
- type NestedDrawerVisibilityProps,
-} from "@/base/components/utils/modal";
+ NestedSidebarDrawer,
+ SidebarDrawer,
+ type NestedSidebarDrawerVisibilityProps,
+} from "@/base/components/mui/SidebarDrawer";
+import { Titlebar } from "@/base/components/Titlebar";
+import { useModalVisibility } from "@/base/components/utils/modal";
import {
getLocaleInUse,
setLocaleInUse,
@@ -24,7 +25,7 @@ import React, { useEffect } from "react";
import { AdvancedSettings } from "./AdvancedSettings";
import { MapSettings } from "./MapSetting";
-export const Preferences: React.FC<NestedDrawerVisibilityProps> = ({
+export const Preferences: React.FC<NestedSidebarDrawerVisibilityProps> = ({
open,
onClose,
onRootClose,
@@ -48,6 +49,7 @@ export const Preferences: React.FC<NestedDrawerVisibilityProps> = ({
};
const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {
+ console.log(reason);
if (reason === "backdropClick") {
handleRootClose();
} else {
@@ -60,9 +62,10 @@ export const Preferences: React.FC<NestedDrawerVisibilityProps> = ({
transitionDuration={0}
open={open}
onClose={handleDrawerClose}
- BackdropProps={{
- sx: { "&&&": { backgroundColor: "transparent" } },
- }}
+ // hideBackdrop
+ // BackdropProps={{
+ // sx: { "&&&": { backgroundColor: "transparent" } },
+ // }}
>
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
diff --git a/web/packages/base/components/mui/SidebarDrawer.tsx b/web/packages/base/components/mui/SidebarDrawer.tsx
index 9248827985..757fd9c9c5 100644
--- a/web/packages/base/components/mui/SidebarDrawer.tsx
+++ b/web/packages/base/components/mui/SidebarDrawer.tsx
@@ -39,10 +39,20 @@ 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 two knobs:
+ // modify a few knobs:
//
// 1. Disable the transition (otherwise our nested drawer visibly slides in
// from the wrong direction).
@@ -50,5 +60,12 @@ export const NestedSidebarDrawer: React.FC<
// 2. Disable the backdrop (otherwise we'd end up with two of them - one
// from the original drawer, and one from this nested one).
//
- <SidebarDrawer transitionDuration={0} hideBackdrop {...props} />
-);
+ return (
+ <SidebarDrawer
+ transitionDuration={0}
+ hideBackdrop
+ onClose={handleClose}
+ {...rest}
+ />
+ );
+};