Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ClipboardCopy): Add string[] type to children #11177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
/** 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 @@
// 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
Loading