From e82ddf9e7e430f9b10b9ba4b2475ed90393e4df1 Mon Sep 17 00:00:00 2001 From: Zolotykh Nikita Date: Tue, 20 Aug 2024 17:45:02 +0300 Subject: [PATCH] feat: add click handler pror for long value --- src/lib/kit/components/LongValue/LongValue.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/kit/components/LongValue/LongValue.tsx b/src/lib/kit/components/LongValue/LongValue.tsx index 76692880..4c4e00b3 100644 --- a/src/lib/kit/components/LongValue/LongValue.tsx +++ b/src/lib/kit/components/LongValue/LongValue.tsx @@ -12,14 +12,21 @@ const b = block('long-value'); export interface LongValueProps extends TextProps { value?: string | number | boolean; + onClick?: (e: React.MouseEvent) => void; } -export const LongValue: React.FC = ({value, className, ...restProps}) => { +export const LongValue: React.FC = ({value, onClick, className, ...restProps}) => { const ref = React.useRef(null); const [open, setOpen] = React.useState(false); const [long, setLong] = React.useState(false); - const handleClick = React.useCallback(() => setOpen((f) => !f), [setOpen]); + const handleClick = React.useCallback( + (e: React.MouseEvent) => { + onClick?.(e); + setOpen((f) => !f); + }, + [setOpen, onClick], + ); React.useEffect(() => { if (ref.current) {