Commit fa64d7ec by Torkel Ödegaard Committed by GitHub

Alert: Fix forwardRef warning (#29577)

parent b63e6959
...@@ -9,7 +9,7 @@ import { getColorsFromSeverity } from '../../utils/colors'; ...@@ -9,7 +9,7 @@ import { getColorsFromSeverity } from '../../utils/colors';
export type AlertVariant = 'success' | 'warning' | 'error' | 'info'; export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
export interface Props extends HTMLAttributes<HTMLElement> { export interface Props extends HTMLAttributes<HTMLDivElement> {
title: string; title: string;
/** On click handler for alert button, mostly used for dismissing the alert */ /** On click handler for alert button, mostly used for dismissing the alert */
onRemove?: (event: React.MouseEvent) => void; onRemove?: (event: React.MouseEvent) => void;
...@@ -39,13 +39,13 @@ function getIconFromSeverity(severity: AlertVariant): string { ...@@ -39,13 +39,13 @@ function getIconFromSeverity(severity: AlertVariant): string {
} }
} }
export const Alert: FC<Props> = React.forwardRef<HTMLElement, Props>( export const Alert: FC<Props> = React.forwardRef<HTMLDivElement, Props>(
({ title, buttonText, onButtonClick, onRemove, children, buttonContent, severity = 'error', ...restProps }) => { ({ title, buttonText, onButtonClick, onRemove, children, buttonContent, severity = 'error', ...restProps }, ref) => {
const theme = useTheme(); const theme = useTheme();
const styles = getStyles(theme, severity, !!buttonContent); const styles = getStyles(theme, severity, !!buttonContent);
return ( return (
<div className={styles.alert} aria-label={selectors.components.Alert.alert(severity)} {...restProps}> <div ref={ref} className={styles.alert} aria-label={selectors.components.Alert.alert(severity)} {...restProps}>
<div className={styles.icon}> <div className={styles.icon}>
<Icon size="xl" name={getIconFromSeverity(severity) as IconName} /> <Icon size="xl" name={getIconFromSeverity(severity) as IconName} />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment