mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alert: Fix forwardRef warning (#29577)
This commit is contained in:
parent
b63e6959df
commit
fa64d7ece4
@ -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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
|
Loading…
Reference in New Issue
Block a user