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
Fix dialog context error in language popover by using DialogTrigger
Mike Cao9e1a75402fd4
diff --git a/src/components/input/LanguageButton.tsx b/src/components/input/LanguageButton.tsxindex bf5c9ff26..53fca3063 100644--- a/src/components/input/LanguageButton.tsx+++ b/src/components/input/LanguageButton.tsx@@ -1,4 +1,4 @@-import { Button, Dialog, Grid, Icon, MenuTrigger, Popover, Text } from '@umami/react-zen';+import { Button, Dialog, DialogTrigger, Grid, Icon, Popover, Text } from '@umami/react-zen';import { Globe } from 'lucide-react';import { useLocale } from '@/components/hooks';import { languages } from '@/lib/lang';@@ -7,12 +7,13 @@ export function LanguageButton() {const { locale, saveLocale } = useLocale();const items = Object.keys(languages).map(key => ({ ...languages[key], value: key }));- function handleSelect(value: string) {+ function handleSelect(value: string, close: () => void) {saveLocale(value);+ close();}return (- <MenuTrigger key="language">+ <DialogTrigger key="language"><Button variant="quiet"><Icon color="primary"><Globe />@@ -20,22 +21,24 @@ export function LanguageButton() {</Button><Popover side="bottom" align="end"><Dialog>- <Grid columns="repeat(3, minmax(200px, 1fr))" overflow="hidden">- {items.map(({ value, label }) => {- return (- <Button key={value} variant="quiet" onPress={() => handleSelect(value)}>- <Text- weight={value === locale ? 'bold' : 'medium'}- color={value === locale ? undefined : 'muted'}- >- {label}- </Text>- </Button>- );- })}- </Grid>+ {({ close }) => (+ <Grid columns="repeat(3, minmax(200px, 1fr))" overflow="hidden">+ {items.map(({ value, label }) => {+ return (+ <Button key={value} variant="quiet" onPress={() => handleSelect(value, close)}>+ <Text+ weight={value === locale ? 'bold' : 'medium'}+ color={value === locale ? undefined : 'muted'}+ >+ {label}+ </Text>+ </Button>+ );+ })}+ </Grid>+ )}</Dialog></Popover>- </MenuTrigger>+ </DialogTrigger>);}