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
guard the localStorage read and drop the empty span placeholder
Yane63a2aec4451
diff --git a/src/components/common/DataGrid.tsx b/src/components/common/DataGrid.tsxindex 4ac8e72af..7d790c050 100644--- a/src/components/common/DataGrid.tsx+++ b/src/components/common/DataGrid.tsx@@ -57,9 +57,13 @@ export function DataGrid({const [search, setSearch] = useState(queryParams?.search || data?.search || '');const showPager = allowPaging && data && data.count > data.pageSize;const { isMobile } = useMobile();- const [userDisplayMode, setUserDisplayMode] = useState<DisplayMode | null>(- () => getItem(DISPLAY_MODE_STORAGE_KEY) ?? null,- );+ const [userDisplayMode, setUserDisplayMode] = useState<DisplayMode | null>(() => {+ // localStorage can hold anything (extensions, manual edits, schema drift),+ // so accept only the two values we know how to render and otherwise fall+ // back to the useMobile-driven default.+ const stored = getItem(DISPLAY_MODE_STORAGE_KEY);+ return stored === 'table' || stored === 'cards' ? stored : null;+ });// Effective mode: explicit user choice wins, otherwise fall back to the// mobile-driven default (cards on small viewports, table elsewhere).@@ -100,8 +104,8 @@ export function DataGrid({return (<Column gap="4" minHeight="300px">- <Row alignItems="center" justifyContent="space-between" wrap="wrap" gap>- {allowSearch ? (+ <Row alignItems="center" wrap="wrap" gap>+ {allowSearch && (<SearchFieldvalue={search}onSearch={handleSearch}@@ -109,10 +113,8 @@ export function DataGrid({autoFocus={autoFocus}placeholder={t(labels.search)}/>- ) : (- <span />)}- <Row alignItems="center" gap>+ <Row alignItems="center" gap style={{ marginLeft: 'auto' }}>{renderActions?.()}{viewToggleButton}</Row>