From 70752824319cb84d0361b7c65e3585159863daa1 Mon Sep 17 00:00:00 2001 From: Anton Ulyanov Date: Fri, 17 Jan 2025 14:14:25 +0300 Subject: [PATCH] StatsHouse UI: feature copy max host --- .../components2/Plot/PlotLegend/PlotLegendMaxHost.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/statshouse-ui/src/components2/Plot/PlotLegend/PlotLegendMaxHost.tsx b/statshouse-ui/src/components2/Plot/PlotLegend/PlotLegendMaxHost.tsx index 9c59f155a..35ef465e1 100644 --- a/statshouse-ui/src/components2/Plot/PlotLegend/PlotLegendMaxHost.tsx +++ b/statshouse-ui/src/components2/Plot/PlotLegend/PlotLegendMaxHost.tsx @@ -34,6 +34,14 @@ export const PlotLegendMaxHost = memo(function PlotLegendMaxHost({ }); }, [idx, maxHostLists]); + const copyItem = useCallback((value?: string | string[]) => { + if (typeof value === 'string') { + window.navigator.clipboard.writeText(value).then(() => { + debug.log(`clipboard ${value}`); + }); + } + }, []); + const options = useMemo(() => maxHostLists[idx - 1] ?? [], [idx, maxHostLists]); return (
@@ -43,8 +51,10 @@ export const PlotLegendMaxHost = memo(function PlotLegendMaxHost({ value={value} placeholder={placeholder} options={options} + onChange={copyItem} listOnlyOpen showCountItems + valueToInput />