From 1325248c6e38c39c352b55ccd9afea413a89202e Mon Sep 17 00:00:00 2001 From: Freya Gustavsson Date: Wed, 13 Nov 2024 13:43:22 +0100 Subject: [PATCH] fix(ClipboardCopy): Add string[] type to children The ClipboardCopy component already handles string[] but didn't have it written in the props as valid. --- .../react-core/src/components/ClipboardCopy/ClipboardCopy.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index 626844355ae..d58a4fa2783 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -89,7 +89,7 @@ export interface ClipboardCopyProps extends Omit /** A function that is triggered on changing the text. */ onChange?: (event: React.FormEvent, text?: string) => void; /** The text which is copied. */ - children: string; + children: string | string[]; /** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */ additionalActions?: React.ReactNode; /** Value to overwrite the randomly generated data-ouia-component-id.*/ @@ -134,7 +134,7 @@ class ClipboardCopy extends React.Component { if (prevProps.children !== this.props.children) { - const newText = this.props.children as string; + const newText = Array.isArray(this.props.children) ? this.props.children.join('') : (this.props.children as string); this.setState({ text: newText, textWhenExpanded: newText }); } };