Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Make mobile menu sheet height responsive and support controlled state
Mike Caob5e9f7d968d1
diff --git a/src/app/(main)/MobileNav.tsx b/src/app/(main)/MobileNav.tsxindex 1ef458638..85af5e220 100644--- a/src/app/(main)/MobileNav.tsx+++ b/src/app/(main)/MobileNav.tsx@@ -49,13 +49,7 @@ export function MobileNav() {<MobileMenuButton>{({ close }) => {return (- <Column- gap="2"- display="flex"- flex-direction="column"- padding="1"- style={{ height: '100dvh' }}- >+ <Column gap="2" display="flex" flex-direction="column" padding="1" height="100%">{isMain &&links.map(link => {return (diff --git a/src/components/input/MobileMenuButton.tsx b/src/components/input/MobileMenuButton.tsxindex 76809e66f..985486167 100644--- a/src/components/input/MobileMenuButton.tsx+++ b/src/components/input/MobileMenuButton.tsx@@ -1,16 +1,44 @@-import { Button, Dialog, type DialogProps, DialogTrigger, Icon, Sheet } from '@umami/react-zen';+import {+ Button,+ type DialogRenderProps,+ DialogTrigger,+ Icon,+ Sheet,+ type SheetProps,+} from '@umami/react-zen';+import { type ReactNode, useState } from 'react';import { Menu } from '@/components/icons';-export function MobileMenuButton(props: DialogProps) {+export interface MobileMenuButtonProps extends Omit<SheetProps, 'children' | 'side'> {+ children?: ReactNode | ((props: DialogRenderProps) => ReactNode);+}++export function MobileMenuButton({+ children,+ isOpen: controlledOpen,+ onOpenChange,+ ...props+}: MobileMenuButtonProps) {+ const [uncontrolledOpen, setUncontrolledOpen] = useState(false);+ const isOpen = controlledOpen ?? uncontrolledOpen;+ const handleOpenChange = (open: boolean) => {+ if (controlledOpen === undefined) {+ setUncontrolledOpen(open);+ }+ onOpenChange?.(open);+ };+return (- <DialogTrigger>+ <DialogTrigger isOpen={isOpen} onOpenChange={handleOpenChange}><Button><Icon><Menu /></Icon></Button>- <Sheet side="left">- <Dialog {...props} style={{ width: 'auto' }} />+ <Sheet {...props} side="left">+ {typeof children === 'function'+ ? children({ close: () => handleOpenChange(false) })+ : children}</Sheet></DialogTrigger>);