⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(web): restore the backdrop behind settings modals
Andrej71e429e3482e
diff --git a/apps/web/src/components/SettingsSidebar.tsx b/apps/web/src/components/SettingsSidebar.tsxindex a0be64269..3eed27919 100644--- a/apps/web/src/components/SettingsSidebar.tsx+++ b/apps/web/src/components/SettingsSidebar.tsx@@ -5,29 +5,50 @@ import {type ReactElement,type ReactNode,useContext,+ useMemo,} from "react";import { useTranslation } from "react-i18next";import { Button } from "@/components/ui/button";import {+ Sheet,SheetDescription,SheetHeader,SheetPopup,SheetTitle,} from "@/components/ui/sheet";-const SettingsWorkspaceIdContext = createContext<string | undefined>(undefined);+type SettingsSidebarContextValue = {+ workspaceId?: string;+ menuOpen: boolean;+ setMenuOpen: (open: boolean) => void;+};++const SettingsSidebarContext = createContext<SettingsSidebarContextValue>({+ workspaceId: undefined,+ menuOpen: false,+ setMenuOpen: () => {},+});export function SettingsSidebarProvider({children,workspaceId,+ menuOpen,+ setMenuOpen,}: {children: ReactNode;workspaceId?: string;+ menuOpen: boolean;+ setMenuOpen: (open: boolean) => void;}): ReactElement {+ const value = useMemo(+ () => ({ workspaceId, menuOpen, setMenuOpen }),+ [workspaceId, menuOpen, setMenuOpen],+ );+return (- <SettingsWorkspaceIdContext.Provider value={workspaceId}>+ <SettingsSidebarContext.Provider value={value}>{children}- </SettingsWorkspaceIdContext.Provider>+ </SettingsSidebarContext.Provider>);}@@ -38,42 +59,46 @@ export default function SettingsSidebar({}): ReactElement {const { t } = useTranslation();const navigate = useNavigate();- const workspaceId = useContext(SettingsWorkspaceIdContext);+ const { workspaceId, menuOpen, setMenuOpen } = useContext(+ SettingsSidebarContext,+ );return (<><aside className="hidden w-64 shrink-0 md:block">{children}</aside>- <SheetPopup- side="left"- className="w-64 bg-sidebar p-0 text-sidebar-foreground md:hidden"- >- <SheetHeader className="sr-only">- <SheetTitle>{t("common:sidebar.title")}</SheetTitle>- <SheetDescription>- {t("common:sidebar.mobileDescription")}- </SheetDescription>- </SheetHeader>- <div className="border-b border-sidebar-border p-2 pr-14">- <Button- variant="ghost"- size="sm"- disabled={!workspaceId}- className="w-full justify-start text-sm font-normal"- onClick={() => {- if (!workspaceId) return;+ <Sheet onOpenChange={setMenuOpen} open={menuOpen}>+ <SheetPopup+ side="left"+ className="w-64 bg-sidebar p-0 text-sidebar-foreground md:hidden"+ >+ <SheetHeader className="sr-only">+ <SheetTitle>{t("common:sidebar.title")}</SheetTitle>+ <SheetDescription>+ {t("common:sidebar.mobileDescription")}+ </SheetDescription>+ </SheetHeader>+ <div className="border-b border-sidebar-border p-2 pr-14">+ <Button+ variant="ghost"+ size="sm"+ disabled={!workspaceId}+ className="w-full justify-start text-sm font-normal"+ onClick={() => {+ if (!workspaceId) return;- navigate({- to: "/dashboard/workspace/$workspaceId",- params: { workspaceId },- });- }}- >- <ChevronLeft aria-hidden="true" className="size-4" />- {t("navigation:page.backToWorkspace")}- </Button>- </div>- {children}- </SheetPopup>+ navigate({+ to: "/dashboard/workspace/$workspaceId",+ params: { workspaceId },+ });+ }}+ >+ <ChevronLeft aria-hidden="true" className="size-4" />+ {t("navigation:page.backToWorkspace")}+ </Button>+ </div>+ {children}+ </SheetPopup>+ </Sheet></>);}diff --git a/apps/web/src/components/settings-sidebar.test.tsx b/apps/web/src/components/settings-sidebar.test.tsxnew file mode 100644index 000000000..7b9603425--- /dev/null+++ b/apps/web/src/components/settings-sidebar.test.tsx@@ -0,0 +1,96 @@+import { cleanup, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";+import SettingsSidebar, {+ SettingsSidebarProvider,+} from "@/components/SettingsSidebar";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";+import { Sheet } from "@/components/ui/sheet";++vi.mock("@tanstack/react-router", () => ({+ useNavigate: () => vi.fn(),+}));++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+ initReactI18next: { type: "3rdParty", init: () => {} },+}));++function renderSettings({ menuOpen }: { menuOpen: boolean }) {+ return render(+ <SettingsSidebarProvider+ workspaceId="workspace-1"+ menuOpen={menuOpen}+ setMenuOpen={vi.fn()}+ >+ <div className="flex">+ <SettingsSidebar>+ <span>Account nav</span>+ </SettingsSidebar>+ <AlertDialog open>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Delete your account?</AlertDialogTitle>+ </AlertDialogHeader>+ </AlertDialogContent>+ </AlertDialog>+ </div>+ </SettingsSidebarProvider>,+ );+}++afterEach(() => {+ cleanup();+});++describe("SettingsSidebar", () => {+ it("renders only the desktop sidebar while the mobile menu is closed", () => {+ renderSettings({ menuOpen: false });++ expect(screen.getAllByText("Account nav")).toHaveLength(1);+ });++ it("renders the nav in the mobile sheet when the menu is open", () => {+ renderSettings({ menuOpen: true });++ expect(screen.getAllByText("Account nav")).toHaveLength(2);+ });++ it("keeps page dialogs out of the settings sheet's dialog tree", () => {+ renderSettings({ menuOpen: false });++ expect(screen.getByText("Delete your account?")).toBeTruthy();+ expect(+ document.querySelector('[data-slot="alert-dialog-backdrop"]'),+ ).not.toBeNull();+ expect(+ document+ .querySelector('[data-slot="alert-dialog-popup"]')+ ?.hasAttribute("data-nested"),+ ).toBe(false);+ });++ it("treats a dialog inside the sheet's root as nested, which is what the old layout did", () => {+ render(+ <Sheet open={false}>+ <AlertDialog open>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Nested</AlertDialogTitle>+ </AlertDialogHeader>+ </AlertDialogContent>+ </AlertDialog>+ </Sheet>,+ );++ expect(+ document+ .querySelector('[data-slot="alert-dialog-popup"]')+ ?.hasAttribute("data-nested"),+ ).toBe(true);+ });+});diff --git a/apps/web/src/components/ui/alert-dialog.tsx b/apps/web/src/components/ui/alert-dialog.tsxindex 1af66ad66..50421a26a 100644--- a/apps/web/src/components/ui/alert-dialog.tsx+++ b/apps/web/src/components/ui/alert-dialog.tsx@@ -23,7 +23,7 @@ function AlertDialogBackdrop({return (<AlertDialogPrimitive.BackdropclassName={cn(- "fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-200 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-black/50 backdrop-blur-[6px] transition-opacity duration-200 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="alert-dialog-backdrop"@@ -57,7 +57,7 @@ function AlertDialogPopup({}) {return (<AlertDialogPortal>- <AlertDialogBackdrop />+ <AlertDialogBackdrop forceRender /><AlertDialogViewportclassName={cn(bottomStickOnMobile &&diff --git a/apps/web/src/components/ui/dialog.tsx b/apps/web/src/components/ui/dialog.tsxindex c884efce4..f826d8fa1 100644--- a/apps/web/src/components/ui/dialog.tsx+++ b/apps/web/src/components/ui/dialog.tsx@@ -61,7 +61,7 @@ function DialogBackdrop({return (<DialogPrimitive.BackdropclassName={cn(- "fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-black/50 backdrop-blur-[6px] transition-opacity duration-200 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="dialog-backdrop"@@ -98,7 +98,7 @@ function DialogPopup({}) {return (<DialogPortal>- <DialogBackdrop />+ <DialogBackdrop forceRender /><DialogViewportclassName={cn(bottomStickOnMobile &&diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings.tsxindex 0d888b342..be1a303c0 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings.tsx@@ -10,7 +10,6 @@ import { useTranslation } from "react-i18next";import PageTitle from "@/components/page-title";import { SettingsSidebarProvider } from "@/components/SettingsSidebar";import { Button } from "@/components/ui/button";-import { Sheet, SheetTrigger } from "@/components/ui/sheet";import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";import useGetProjects from "@/hooks/queries/project/use-get-projects";import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";@@ -62,27 +61,24 @@ function SettingsLayout() {}, [isMobile]);return (- <Sheet open={settingsMenuOpen} onOpenChange={setSettingsMenuOpen}>+ <><PageTitle title={t("navigation:page.settingsTitle")} /><div className="flex h-full w-full flex-col bg-sidebar p-2 sm:p-4"><div className="relative flex h-full min-h-0 flex-col gap-6 overflow-hidden rounded-md border border-border bg-card p-3 md:gap-4 sm:p-4"><div className="shrink-0"><div className="flex items-center">- <SheetTrigger- render={- <Button- type="button"- variant="ghost"- size="icon-sm"- className="shrink-0 md:hidden"- aria-label="Open settings menu"- title="Open settings menu"- />- }+ <Button+ type="button"+ variant="ghost"+ size="icon-sm"+ className="shrink-0 md:hidden"+ aria-label="Open settings menu"+ title="Open settings menu"+ onClick={() => setSettingsMenuOpen(true)}><PanelLeftIcon className="size-4" />- </SheetTrigger>+ </Button><div className="flex items-center gap-1 md:hidden"><ChevronLeft className="size-4 text-muted-foreground" />@@ -159,12 +155,16 @@ function SettingsLayout() {</div><div className="min-h-0 flex-1 overflow-y-auto">- <SettingsSidebarProvider workspaceId={workspace?.id}>+ <SettingsSidebarProvider+ workspaceId={workspace?.id}+ menuOpen={settingsMenuOpen}+ setMenuOpen={setSettingsMenuOpen}+ ><Outlet /></SettingsSidebarProvider></div></div></div>- </Sheet>+ </>);}