diff --git a/packages/react-core/src/components/Label/Label.tsx b/packages/react-core/src/components/Label/Label.tsx index 9cd2891103f..46ac5601d23 100644 --- a/packages/react-core/src/components/Label/Label.tsx +++ b/packages/react-core/src/components/Label/Label.tsx @@ -232,30 +232,31 @@ export const Label: React.FunctionComponent = ({ setCurrValue(editableInputRef.current.value); }; - let labelComponentChild = {content}; - + let LabelComponentChildElement = 'span'; if (href) { - labelComponentChild = ( - - {content} - - ); + LabelComponentChildElement = 'a'; } else if (isEditable) { - labelComponentChild = ( - - ); + LabelComponentChildElement = 'button'; } + const labelComponentChildProps = { + className: css(styles.labelContent), + ...(isTooltipVisible && { tabIndex: 0 }), + ...(href && { href }), + ...(isEditable && { + ref: editableButtonRef, + onClick: (e: React.MouseEvent) => { + setIsEditableActive(true); + e.stopPropagation(); + }, + ...editableProps + }) + }; + + let labelComponentChild = ( + {content} + ); + if (render) { labelComponentChild = (