Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/components/badge/beta_badge/beta_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ type WithSpanProps = Omit<
>;

// `label` prop can be a `ReactNode` only if `title` or `tooltipContent` is provided
type LabelAsNode = (
| {
title: string;
tooltipContent?: ReactNode;
}
| {
tooltipContent: ReactNode;
title?: string;
}
) & {
type LabelAsNode = ExclusiveUnion<
{
title: string;
tooltipContent?: ReactNode;
},
{
tooltipContent: ReactNode;
title?: string;
}
> & {
label: ReactNode;
};

Expand Down Expand Up @@ -203,12 +203,11 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({

let content;
if (onClick || href) {
const spanTitle = title || label;
content = (
<Element
aria-label={onClickAriaLabel}
className={classes}
title={spanTitle as string | undefined}
title={typeof label === 'string' ? label : title}
{...(relObj as HTMLAttributes<HTMLElement>)}
{...(rest as HTMLAttributes<HTMLElement>)}>
{icon || label}
Expand Down Expand Up @@ -246,10 +245,7 @@ export const EuiBetaBadge: FunctionComponent<EuiBetaBadgeProps> = ({
);
}
return (
<span
className={classes}
title={spanTitle as string | undefined}
{...rest}>
<span className={classes} title={spanTitle as string} {...rest}>
{icon || label}
</span>
);
Expand Down