Skip to content

Commit

Permalink
fix(ClipboardCopy): Add string[] type to children
Browse files Browse the repository at this point in the history
The ClipboardCopy component already handles string[] but didn't have it
written in the props as valid.
  • Loading branch information
Venefilyn committed Nov 18, 2024
1 parent d6fa6b4 commit 1325248
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
/** 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.*/
Expand Down Expand Up @@ -134,7 +134,7 @@ class ClipboardCopy extends React.Component<ClipboardCopyProps, ClipboardCopySta
// eslint-disable-next-line @typescript-eslint/no-unused-vars
componentDidUpdate = (prevProps: ClipboardCopyProps, prevState: ClipboardCopyState) => {
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);

Check failure on line 137 in packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `·?·this.props.children.join('')` with `⏎········?·this.props.children.join('')⏎·······`
this.setState({ text: newText, textWhenExpanded: newText });
}
};
Expand Down

0 comments on commit 1325248

Please sign in to comment.