Skip to content

Commit 0a65ff1

Browse files
author
Eric Olkowski
committed
Forwarded ref
1 parent abc6eb4 commit 0a65ff1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/react-core/src/components/Truncate/Truncate.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment, useEffect, useRef, useState } from 'react';
1+
import { Fragment, useEffect, useRef, useState, forwardRef } from 'react';
22
import styles from '@patternfly/react-styles/css/components/Truncate/truncate';
33
import { css } from '@patternfly/react-styles';
44
import { Tooltip, TooltipPosition, TooltipProps } from '../Tooltip';
@@ -59,11 +59,13 @@ export interface TruncateProps extends Omit<React.HTMLProps<HTMLSpanElement | HT
5959
| 'right-end';
6060
/** Additional props to pass to the tooltip. */
6161
tooltipProps?: Omit<TooltipProps, 'content'>;
62+
/** @hide Forwarded ref */
63+
innerRef?: React.Ref<any>;
6264
}
6365

6466
const sliceTrailingContent = (str: string, slice: number) => [str.slice(0, str.length - slice), str.slice(-slice)];
6567

66-
export const Truncate: React.FunctionComponent<TruncateProps> = ({
68+
const TruncateBase: React.FunctionComponent<TruncateProps> = ({
6769
className,
6870
href,
6971
position = 'end',
@@ -258,4 +260,8 @@ export const Truncate: React.FunctionComponent<TruncateProps> = ({
258260
);
259261
};
260262

263+
export const Truncate = forwardRef((props: TruncateProps, ref: React.Ref<HTMLAnchorElement | HTMLSpanElement>) => (
264+
<TruncateBase innerRef={ref} {...props} />
265+
));
266+
261267
Truncate.displayName = 'Truncate';

0 commit comments

Comments
 (0)