From 28511503d1c3858b319fc4a8a50fbf41071c4971 Mon Sep 17 00:00:00 2001 From: gitdallas Date: Fri, 13 Oct 2023 08:26:40 -0500 Subject: [PATCH 1/4] bug(ClipboardCopy): change children type to string Signed-off-by: gitdallas --- .../react-core/src/components/ClipboardCopy/ClipboardCopy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index bb70d7af704..c05da1cd313 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -74,7 +74,7 @@ export interface ClipboardCopyProps extends Omit /** A function that is triggered on changing the text. */ onChange?: (event: React.FormEvent, text?: string | number) => void; /** The text which is copied. */ - children: React.ReactNode; + children: 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.*/ From fed5a902a9998db5d5e62a9581fc388ce60fd86e Mon Sep 17 00:00:00 2001 From: gitdallas Date: Fri, 13 Oct 2023 10:05:53 -0500 Subject: [PATCH 2/4] fix clipboardcopyexpanded to work with string children Signed-off-by: gitdallas --- .../react-core/src/components/ClipboardCopy/ClipboardCopy.tsx | 4 ++-- .../src/components/ClipboardCopy/ClipboardCopyExpanded.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index c05da1cd313..19b09117279 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -26,7 +26,7 @@ export interface ClipboardCopyState { copied: boolean; } -export interface ClipboardCopyProps extends Omit, 'onChange'>, OUIAProps { +export interface ClipboardCopyProps extends Omit, 'onChange' | 'children'>, OUIAProps { /** Additional classes added to the clipboard copy container. */ className?: string; /** Tooltip message to display when hover the copy button */ @@ -268,7 +268,7 @@ class ClipboardCopy extends React.Component - {this.state.text} + {this.state.text as string} )} diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx index 8a82c3e0001..0c805495078 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx @@ -6,7 +6,6 @@ import { PickOptional } from '../../helpers/typeUtils'; export interface ClipboardCopyExpandedProps extends Omit { className?: string; - children: React.ReactNode; onChange?: (e: React.FormEvent, text: string) => void; isReadOnly?: boolean; isCode?: boolean; From 692562f5623382ea153b733461e91f924dedd189 Mon Sep 17 00:00:00 2001 From: gitdallas Date: Thu, 19 Oct 2023 15:37:51 -0500 Subject: [PATCH 3/4] refactor a bit --- .../ClipboardCopy/ClipboardCopy.tsx | 20 +++++++++---------- .../src/components/Wizard/Wizard.tsx | 16 +++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index 19b09117279..07eea690623 100644 --- a/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -10,7 +10,7 @@ import { ClipboardCopyToggle } from './ClipboardCopyToggle'; import { ClipboardCopyExpanded } from './ClipboardCopyExpanded'; import { getOUIAProps, OUIAProps } from '../../helpers'; -export const clipboardCopyFunc = (event: React.ClipboardEvent, text?: React.ReactNode) => { +export const clipboardCopyFunc = (event: React.ClipboardEvent, text?: string) => { navigator.clipboard.writeText(text.toString()); }; @@ -21,7 +21,7 @@ export enum ClipboardCopyVariant { } export interface ClipboardCopyState { - text: string | number; + text: string; expanded: boolean; copied: boolean; } @@ -70,9 +70,9 @@ export interface ClipboardCopyProps extends Omit /** Delay in ms before the tooltip appears. */ entryDelay?: number; /** A function that is triggered on clicking the copy button. */ - onCopy?: (event: React.ClipboardEvent, text?: React.ReactNode) => void; + onCopy?: (event: React.ClipboardEvent, text?: string) => void; /** A function that is triggered on changing the text. */ - onChange?: (event: React.FormEvent, text?: string | number) => void; + onChange?: (event: React.FormEvent, text?: string) => void; /** The text which is copied. */ children: string; /** Additional actions for inline clipboard copy. Should be wrapped with ClipboardCopyAction. */ @@ -89,9 +89,7 @@ class ClipboardCopy extends React.Component { if (prevProps.children !== this.props.children) { - this.setState({ text: this.props.children as string | number }); + this.setState({ text: this.props.children as string }); } }; @@ -136,7 +134,7 @@ class ClipboardCopy extends React.Component { + updateText = (event: React.FormEvent, text: string) => { this.setState({ text }); this.props.onChange(event, text); }; @@ -239,7 +237,7 @@ class ClipboardCopy extends React.Component - {this.state.text as string} + {this.state.text} )} diff --git a/packages/react-core/src/components/Wizard/Wizard.tsx b/packages/react-core/src/components/Wizard/Wizard.tsx index e12e513ca83..2aabacadaed 100644 --- a/packages/react-core/src/components/Wizard/Wizard.tsx +++ b/packages/react-core/src/components/Wizard/Wizard.tsx @@ -30,8 +30,6 @@ export interface WizardProps extends React.HTMLProps { footer?: WizardFooterType; /** Wizard navigation */ nav?: WizardNavType; - /** Aria-label for the Nav */ - navAriaLabel?: string; /** The initial index the wizard is to start on (1 or higher). Defaults to 1. */ startIndex?: number; /** Additional classes spread to the wizard */ @@ -65,7 +63,6 @@ export const Wizard = ({ className, header, nav, - navAriaLabel, startIndex = 1, isVisitRequired = false, isProgressive = false, @@ -179,12 +176,7 @@ export const Wizard = ({ {...wrapperProps} > {header} - + ); @@ -192,10 +184,9 @@ export const Wizard = ({ const WizardInternal = ({ nav, - navAriaLabel, isVisitRequired, isProgressive -}: Pick) => { +}: Pick) => { const { activeStep, steps, footer, goToStepByIndex } = useWizardContext(); const [isNavExpanded, setIsNavExpanded] = React.useState(false); @@ -207,13 +198,12 @@ const WizardInternal = ({ return ( ); - }, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, navAriaLabel, steps]); + }, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, steps]); return ( Date: Thu, 19 Oct 2023 15:42:21 -0500 Subject: [PATCH 4/4] fix bad rebase --- .../react-core/src/components/Wizard/Wizard.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/react-core/src/components/Wizard/Wizard.tsx b/packages/react-core/src/components/Wizard/Wizard.tsx index 2aabacadaed..e12e513ca83 100644 --- a/packages/react-core/src/components/Wizard/Wizard.tsx +++ b/packages/react-core/src/components/Wizard/Wizard.tsx @@ -30,6 +30,8 @@ export interface WizardProps extends React.HTMLProps { footer?: WizardFooterType; /** Wizard navigation */ nav?: WizardNavType; + /** Aria-label for the Nav */ + navAriaLabel?: string; /** The initial index the wizard is to start on (1 or higher). Defaults to 1. */ startIndex?: number; /** Additional classes spread to the wizard */ @@ -63,6 +65,7 @@ export const Wizard = ({ className, header, nav, + navAriaLabel, startIndex = 1, isVisitRequired = false, isProgressive = false, @@ -176,7 +179,12 @@ export const Wizard = ({ {...wrapperProps} > {header} - + ); @@ -184,9 +192,10 @@ export const Wizard = ({ const WizardInternal = ({ nav, + navAriaLabel, isVisitRequired, isProgressive -}: Pick) => { +}: Pick) => { const { activeStep, steps, footer, goToStepByIndex } = useWizardContext(); const [isNavExpanded, setIsNavExpanded] = React.useState(false); @@ -198,12 +207,13 @@ const WizardInternal = ({ return ( ); - }, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, steps]); + }, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, navAriaLabel, steps]); return (