diff --git a/apps/web/src/components/ui/metric/MetricCard.tsx b/apps/web/src/components/ui/metric/MetricCard.tsx index 46e0b2db2..1ba4656b3 100644 --- a/apps/web/src/components/ui/metric/MetricCard.tsx +++ b/apps/web/src/components/ui/metric/MetricCard.tsx @@ -9,105 +9,101 @@ import type { DropdownItems } from '../dropdown'; import Link from 'next/link'; import { PreparingYourRequestLoader } from '../charts/LoadingComponents'; -export const MetricCard = React.memo( - React.forwardRef< - HTMLDivElement, +export const MetricCard = React.forwardRef< + HTMLDivElement, + { + className?: string; + metricId: string; + metricLink: string; + isDragOverlay: boolean; + readOnly: boolean; + metricData: BusterMetricData | undefined; + metric: Pick | undefined; + renderChart: boolean; + loading: boolean; + error: string | undefined; + animate: boolean; + onInitialAnimationEnd?: () => void; + attributes?: DraggableAttributes; + listeners?: DraggableSyntheticListeners; + threeDotMenuItems: DropdownItems; + } +>( + ( { - className?: string; - metricId: string; - metricLink: string; - isDragOverlay: boolean; - readOnly: boolean; - metricData: BusterMetricData | undefined; - metric: - | Pick - | undefined; - renderChart: boolean; - loading: boolean; - error: string | undefined; - animate: boolean; - onInitialAnimationEnd?: () => void; - attributes?: DraggableAttributes; - listeners?: DraggableSyntheticListeners; - threeDotMenuItems: DropdownItems; - } - >( - ( - { - className = '', - metricId, - metricLink, - readOnly, - metricData, - metric, - isDragOverlay, - renderChart = true, - loading = false, - animate = true, - error, - attributes, - listeners, - threeDotMenuItems, - onInitialAnimationEnd - }, - ref - ) => { - const isTable = metric?.chart_config?.selectedChartType === 'table'; - const chartOptions = metric?.chart_config; - const data = metricData?.data || null; - const hideChart = isDragOverlay && data && data.length > 50; + className = '', + metricId, + metricLink, + readOnly, + metricData, + metric, + isDragOverlay, + renderChart = true, + loading = false, + animate = true, + error, + attributes, + listeners, + threeDotMenuItems, + onInitialAnimationEnd + }, + ref + ) => { + const isTable = metric?.chart_config?.selectedChartType === 'table'; + const chartOptions = metric?.chart_config; + const data = metricData?.data || null; + const hideChart = isDragOverlay && data && data.length > 50; - const content = () => { - if (renderChart && chartOptions && !hideChart) { - return ( - { + if (renderChart && chartOptions && !hideChart) { + return ( + + ); + } + + return ; + }; + + return ( + + + + - ); - } + + - return ; - }; - - return ( - - - - - - - -
- {content()} -
-
- ); - } - ) +
+ {content()} +
+
+ ); + } ); diff --git a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx index 9da5a72d5..8947e7f6a 100644 --- a/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx +++ b/apps/web/src/components/ui/metric/MetricCardThreeMenuContainer.tsx @@ -2,39 +2,35 @@ import { cn } from '@/lib/classMerge'; import React, { useState } from 'react'; import { Dropdown, type DropdownItems } from '../dropdown'; -export const MetricCardThreeMenuContainer = React.memo( - ({ - children, - dropdownItems, - className - }: { - className?: string; - children: React.ReactNode; - dropdownItems: DropdownItems; - }) => { - const [isOpen, setIsOpen] = useState(false); +export const MetricCardThreeMenuContainer = ({ + children, + dropdownItems, + className +}: { + className?: string; + children: React.ReactNode; + dropdownItems: DropdownItems; +}) => { + const [isOpen, setIsOpen] = useState(false); - return ( -
{ - e.stopPropagation(); - e.preventDefault(); - }} - className={cn( - // Use opacity and pointer-events instead of display:none to maintain positioning context - 'w-8.5 rounded transition-opacity duration-75', - 'pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100', - className, - isOpen && 'pointer-events-auto opacity-100' - )}> -
- - {children} - -
-
- ); - } -); + return ( +
{ + e.stopPropagation(); + e.preventDefault(); + }} + className={cn( + // Use opacity and pointer-events instead of display:none to maintain positioning context + '-mr-2 hidden group-hover:block', + 'group-hover:pointer-events-auto', + isOpen && 'pointer-events-auto block', + className + )}> + + {children} + +
+ ); +}; MetricCardThreeMenuContainer.displayName = 'MetricCardThreeMenuContainer'; diff --git a/apps/web/src/components/ui/metric/MetricTitle.tsx b/apps/web/src/components/ui/metric/MetricTitle.tsx index 4ea387f90..ff8bec638 100644 --- a/apps/web/src/components/ui/metric/MetricTitle.tsx +++ b/apps/web/src/components/ui/metric/MetricTitle.tsx @@ -20,57 +20,55 @@ export const MetricTitle: React.FC<{ isDragOverlay: boolean; readOnly?: boolean; threeDotMenuItems: DropdownItems; -}> = React.memo( - ({ - readOnly = true, - name, - description, - isDragOverlay, - metricLink, - timeFrame, - threeDotMenuItems - }) => { - const router = useRouter(); +}> = ({ + readOnly = true, + name, + description, + isDragOverlay, + metricLink, + timeFrame, + threeDotMenuItems +}) => { + const router = useRouter(); - useMount(() => { - if (metricLink) router.prefetch(metricLink); - }); + useMount(() => { + if (metricLink) router.prefetch(metricLink); + }); - return ( - <> -
-
- - {`${name}`} - -
- -
- - {timeFrame || '_'} - - {description && timeFrame && ' • '} - - {description} - -
+ return ( +
+
+
+ + {`${name}`} +
- {isDragOverlay || readOnly ? null : ( - -
+ + {isDragOverlay || readOnly ? null : ( + +
+ ); +}; MetricTitle.displayName = 'MetricTitle'; diff --git a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx index 4b6556ce4..6e9bf78cf 100644 --- a/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx +++ b/apps/web/src/controllers/DashboardController/DashboardViewDashboardController/DashboardContentController/DashboardMetricItem/DashboardMetricItem.tsx @@ -1,6 +1,6 @@ 'use client'; -import React, { useMemo,useContext } from 'react'; +import React, { useMemo, useContext } from 'react'; import { useMemoizedFn } from '@/hooks'; import { useDashboardMetric } from './useDashboardMetric'; import { assetParamsToRoute } from '@/lib/assets'; @@ -47,10 +47,8 @@ const DashboardMetricItemBase: React.FC<{ const animate = !initialAnimationEnded && !isDragOverlay && dataLength < 125 && numberOfMetrics <= 30; - const error: string | undefined = useMemo( - () => metric?.error || metricDataError?.message || metricError?.message || undefined, - [metric?.error, metricDataError, metricError] - ); + const error: string | undefined = + metric?.error || metricDataError?.message || metricError?.message || undefined; const metricLink = useMemo(() => { return assetParamsToRoute({ @@ -92,4 +90,4 @@ const DashboardMetricItemBase: React.FC<{ ); }; -export const DashboardMetricItem = React.memo(DashboardMetricItemBase); +export const DashboardMetricItem = DashboardMetricItemBase;