From ce78a76e88d3736e34b13bbd4f9984ba7c01fb0b Mon Sep 17 00:00:00 2001 From: adamviktora Date: Wed, 17 Jan 2024 13:15:41 +0100 Subject: [PATCH] fix(ClipboardCopy): update main content on children change when expanded --- .../src/components/ClipboardCopy/ClipboardCopy.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index 9731360e6ea..1fc674de587 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -120,7 +120,8 @@ class ClipboardCopy extends React.Component { if (prevProps.children !== this.props.children) { - this.setState({ text: this.props.children as string }); + const newText = this.props.children as string; + this.setState({ text: newText, textWhenExpanded: newText }); } }; @@ -252,7 +253,7 @@ class ClipboardCopy extends React.Component { - onCopy(event, this.state.text); + onCopy(event, this.state.expanded ? this.state.textWhenExpanded : this.state.text); this.setState({ copied: true }); }} onTooltipHidden={() => this.setState({ copied: false })}