diff --git a/frontend/src/lib/components/CopyToClipboard.tsx b/frontend/src/lib/components/CopyToClipboard.tsx index 03480644f2d5b..fd8e9c78dd3a7 100644 --- a/frontend/src/lib/components/CopyToClipboard.tsx +++ b/frontend/src/lib/components/CopyToClipboard.tsx @@ -1,10 +1,10 @@ +import clsx from 'clsx' import { IconCopy } from 'lib/lemon-ui/icons' import { LemonButton } from 'lib/lemon-ui/LemonButton' import { Tooltip } from 'lib/lemon-ui/Tooltip' import { copyToClipboard } from 'lib/utils/copyToClipboard' -import { HTMLProps } from 'react' -interface InlinePropsBase extends HTMLProps { +interface InlinePropsBase { description?: string /** Makes text selectable instead of copying on click anywhere */ selectable?: boolean @@ -12,6 +12,8 @@ interface InlinePropsBase extends HTMLProps { tooltipMessage?: string | null iconStyle?: Record iconPosition?: 'end' | 'start' + className?: string + /** @deprecated */ style?: React.CSSProperties } interface InlinePropsWithStringInside extends InlinePropsBase { @@ -33,41 +35,49 @@ export function CopyToClipboardInline({ tooltipMessage = null, iconStyle, iconPosition = 'end', + className, style, ...props }: InlineProps): JSX.Element { const copy = async (): Promise => await copyToClipboard((explicitValue ?? children) as string, description) - const content = ( - - {children && {children}} - } - noPadding - className="ml-1" - data-attr="copy-icon" - onClick={!selectable ? undefined : copy} - /> - + let content = ( + } + noPadding + className="ml-1" + data-attr="copy-icon" + onClick={!selectable ? undefined : copy} + /> ) + + if (children) { + content = ( + + {children} + } + noPadding + className="ml-1" + data-attr="copy-icon" + onClick={!selectable ? undefined : copy} + /> + + ) + } return !selectable || tooltipMessage !== null ? ( {content} ) : (