Skip to content

Commit 2af86aa

Browse files
authored
fix(Truncate): pass forwardRef properly (#11992)
1 parent 7fb9e81 commit 2af86aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment, useEffect, useRef, useState, forwardRef } from 'react';
1+
import { Fragment, useEffect, useRef, useState, forwardRef, useImperativeHandle } 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';
@@ -75,6 +75,7 @@ const TruncateBase: React.FunctionComponent<TruncateProps> = ({
7575
maxCharsDisplayed,
7676
omissionContent = '\u2026',
7777
content,
78+
innerRef,
7879
...props
7980
}: TruncateProps) => {
8081
const [isTruncated, setIsTruncated] = useState(true);
@@ -83,6 +84,7 @@ const TruncateBase: React.FunctionComponent<TruncateProps> = ({
8384
const [shouldRenderByMaxChars, setShouldRenderByMaxChars] = useState(maxCharsDisplayed > 0);
8485

8586
const textRef = useRef<HTMLElement>(null);
87+
useImperativeHandle(innerRef, () => textRef.current!);
8688
const defaultSubParentRef = useRef<any>(null);
8789
const subParentRef = tooltipProps?.triggerRef || defaultSubParentRef;
8890
const observer = useRef(null);

0 commit comments

Comments
 (0)