Skip to content

Commit db7d624

Browse files
author
Eric Olkowski
committed
Feedback from Austin and Katie
1 parent 2509e43 commit db7d624

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ class ClipboardCopy extends React.Component<ClipboardCopyProps, ClipboardCopySta
202202

203203
const copyableText = this.state.text;
204204
const shouldTruncate = variant === ClipboardCopyVariant.inlineCompact && truncation;
205+
const inlineCompactContent = shouldTruncate ? (
206+
<Truncate
207+
refToGetParent={this.clipboardRef}
208+
content={copyableText}
209+
{...(typeof truncation === 'object' && truncation)}
210+
/>
211+
) : (
212+
copyableText
213+
);
205214

206215
return (
207216
<div
@@ -222,28 +231,12 @@ class ClipboardCopy extends React.Component<ClipboardCopyProps, ClipboardCopySta
222231
<React.Fragment>
223232
{!isCode && (
224233
<span className={css(styles.clipboardCopyText)} id={`${textIdPrefix}${id}`}>
225-
{shouldTruncate ? (
226-
<Truncate
227-
refToGetParent={this.clipboardRef}
228-
content={copyableText}
229-
{...(typeof truncation === 'object' && truncation)}
230-
/>
231-
) : (
232-
copyableText
233-
)}
234+
{inlineCompactContent}
234235
</span>
235236
)}
236237
{isCode && (
237238
<code className={css(styles.clipboardCopyText, styles.modifiers.code)} id={`${textIdPrefix}${id}`}>
238-
{shouldTruncate ? (
239-
<Truncate
240-
refToGetParent={this.clipboardRef}
241-
content={copyableText}
242-
{...(typeof truncation === 'object' && truncation)}
243-
/>
244-
) : (
245-
copyableText
246-
)}
239+
{inlineCompactContent}
247240
</code>
248241
)}
249242
<span className={css(styles.clipboardCopyActions)}>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ export interface TruncateProps extends React.HTMLProps<HTMLSpanElement> {
4242
| 'left-end'
4343
| 'right-start'
4444
| 'right-end';
45-
/** The element whose parent to reference when calculating whether truncation should occur. This must be an ancestor
46-
* of the ClipboardCopy, and must have a valid width value.
45+
/** @hide The element whose parent to reference when calculating whether truncation should occur. This must be an ancestor
46+
* of the ClipboardCopy, and must have a valid width value. For internal use only, do not use as it is not part of the public API
47+
* and is subject to change.
4748
*/
4849
refToGetParent?: React.RefObject<any>;
4950
}

0 commit comments

Comments
 (0)