Skip to content

Commit a414253

Browse files
authored
bug(ClipboardCopy): change children type to string (#9743)
* bug(ClipboardCopy): change children type to string Signed-off-by: gitdallas <[email protected]> * fix clipboardcopyexpanded to work with string children Signed-off-by: gitdallas <[email protected]> * refactor a bit * fix bad rebase --------- Signed-off-by: gitdallas <[email protected]>
1 parent 2a70043 commit a414253

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ClipboardCopyToggle } from './ClipboardCopyToggle';
1010
import { ClipboardCopyExpanded } from './ClipboardCopyExpanded';
1111
import { getOUIAProps, OUIAProps } from '../../helpers';
1212

13-
export const clipboardCopyFunc = (event: React.ClipboardEvent<HTMLDivElement>, text?: React.ReactNode) => {
13+
export const clipboardCopyFunc = (event: React.ClipboardEvent<HTMLDivElement>, text?: string) => {
1414
navigator.clipboard.writeText(text.toString());
1515
};
1616

@@ -27,7 +27,7 @@ export interface ClipboardCopyState {
2727
textWhenExpanded: string;
2828
}
2929

30-
export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'>, OUIAProps {
30+
export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange' | 'children'>, OUIAProps {
3131
/** Additional classes added to the clipboard copy container. */
3232
className?: string;
3333
/** Tooltip message to display when hover the copy button */
@@ -71,12 +71,12 @@ export interface ClipboardCopyProps extends Omit<React.HTMLProps<HTMLDivElement>
7171
/** Delay in ms before the tooltip appears. */
7272
entryDelay?: number;
7373
/** A function that is triggered on clicking the copy button. */
74-
onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, text?: React.ReactNode) => void;
74+
onCopy?: (event: React.ClipboardEvent<HTMLDivElement>, text?: string) => void;
7575
/** A function that is triggered on changing the text. */
7676
onChange?: (event: React.FormEvent, text?: string) => void;
7777
/** The text which is copied. */
78-
children: React.ReactNode;
79-
/** Additional actions for inline-compact clipboard copy. Should be wrapped with ClipboardCopyAction. */
78+
children: string;
79+
/** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */
8080
additionalActions?: React.ReactNode;
8181
/** Value to overwrite the randomly generated data-ouia-component-id.*/
8282
ouiaId?: number | string;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { PickOptional } from '../../helpers/typeUtils';
66

77
export interface ClipboardCopyExpandedProps extends Omit<ClipboardCopyProps, 'onChange'> {
88
className?: string;
9-
children: React.ReactNode;
109
onChange?: (e: React.FormEvent<HTMLDivElement>, text: string) => void;
1110
isReadOnly?: boolean;
1211
isCode?: boolean;

0 commit comments

Comments
 (0)