Skip to content

Commit 1325248

Browse files
committed
fix(ClipboardCopy): Add string[] type to children
The ClipboardCopy component already handles string[] but didn't have it written in the props as valid.
1 parent d6fa6b4 commit 1325248

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
8989
/** A function that is triggered on changing the text. */
9090
onChange?: (event: React.FormEvent, text?: string) => void;
9191
/** The text which is copied. */
92-
children: string;
92+
children: string | string[];
9393
/** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */
9494
additionalActions?: React.ReactNode;
9595
/** Value to overwrite the randomly generated data-ouia-component-id.*/
@@ -134,7 +134,7 @@ class ClipboardCopy extends React.Component<ClipboardCopyProps, ClipboardCopySta
134134
// eslint-disable-next-line @typescript-eslint/no-unused-vars
135135
componentDidUpdate = (prevProps: ClipboardCopyProps, prevState: ClipboardCopyState) => {
136136
if (prevProps.children !== this.props.children) {
137-
const newText = this.props.children as string;
137+
const newText = Array.isArray(this.props.children) ? this.props.children.join('') : (this.props.children as string);
138138
this.setState({ text: newText, textWhenExpanded: newText });
139139
}
140140
};

0 commit comments

Comments
 (0)