Commit 62d86c95 by Alex Khomenko Committed by GitHub

Grafana UI: Add forwardRef (#22466)

parent f92f657f
import React, { FC, HTMLProps } from 'react'; import React, { HTMLProps, forwardRef } from 'react';
import { GrafanaTheme } from '@grafana/data'; import { GrafanaTheme } from '@grafana/data';
import { css, cx } from 'emotion'; import { css, cx } from 'emotion';
import { stylesFactory, useTheme } from '../../../themes'; import { stylesFactory, useTheme } from '../../../themes';
...@@ -26,13 +26,13 @@ const getTextAreaStyle = stylesFactory((theme: GrafanaTheme, invalid = false) => ...@@ -26,13 +26,13 @@ const getTextAreaStyle = stylesFactory((theme: GrafanaTheme, invalid = false) =>
}; };
}); });
export const TextArea: FC<Props> = ({ invalid, size = 'auto', ...props }) => { export const TextArea = forwardRef<HTMLTextAreaElement, Props>(({ invalid, size = 'auto', ...props }, ref) => {
const theme = useTheme(); const theme = useTheme();
const styles = getTextAreaStyle(theme, invalid); const styles = getTextAreaStyle(theme, invalid);
return ( return (
<div className={inputSizes()[size]}> <div className={inputSizes()[size]}>
<textarea className={styles.textarea} {...props} /> <textarea ref={ref} className={styles.textarea} {...props} />
</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