Skip to content

Commit a355381

Browse files
feat(ClipboardCopy): added onBlur and onFocus callbacks
1 parent d5053dd commit a355381

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
9191
onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, text?: React.ReactNode) => void;
9292
/** A function that is triggered on changing the text. */
9393
onChange?: (event: React.FormEvent, text?: string) => void;
94+
/** Callback function when text input is focused */
95+
onFocus?: (event?: any) => void;
96+
/** Callback function when text input is blurred (focus leaves) */
97+
onBlur?: (event?: any) => void;
9498
/** The text which is copied. */
9599
children: string | string[];
96100
/** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */
@@ -177,6 +181,8 @@ class ClipboardCopy extends Component<ClipboardCopyProps, ClipboardCopyState> {
177181
/* eslint-disable @typescript-eslint/no-unused-vars */
178182
isExpanded,
179183
onChange, // Don't pass to <div>
184+
onFocus, // Don't pass to <div>
185+
onBlur, // Don't pass to <div>
180186
/* eslint-enable @typescript-eslint/no-unused-vars */
181187
isReadOnly,
182188
isCode,
@@ -297,6 +303,8 @@ class ClipboardCopy extends Component<ClipboardCopyProps, ClipboardCopyState> {
297303
value={this.state.expanded ? this.state.textWhenExpanded : copyableText}
298304
id={`text-input-${id}`}
299305
aria-label={textAriaLabel}
306+
onFocus={onFocus}
307+
onBlur={onBlur}
300308
{...(isCode && { dir: 'ltr' })}
301309
/>
302310
<ClipboardCopyButton

0 commit comments

Comments
 (0)