mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 09:38:11 +08:00
render Truncate's child instead of creating own component to render
This commit is contained in:
@@ -52,18 +52,17 @@ export default class Truncate extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { children, size, fontSize } = this.props;
|
||||||
children,
|
const originalString = children[0].text;
|
||||||
|
const truncatedString = this.maybeTruncateString(
|
||||||
|
originalString,
|
||||||
size,
|
size,
|
||||||
fontSize,
|
fontSize
|
||||||
"data-testid": testID,
|
);
|
||||||
"data-testclass": testClass,
|
children[0].text = truncatedString;
|
||||||
style,
|
|
||||||
} = this.props;
|
|
||||||
const truncatedString = this.maybeTruncateString(children, size, fontSize);
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={children}
|
content={originalString}
|
||||||
disabled={truncatedString === null}
|
disabled={truncatedString === null}
|
||||||
hoverOpenDelay={tooltipHoverOpenDelayQuick}
|
hoverOpenDelay={tooltipHoverOpenDelayQuick}
|
||||||
position={Position.LEFT}
|
position={Position.LEFT}
|
||||||
@@ -73,9 +72,7 @@ export default class Truncate extends Component {
|
|||||||
hide: { enabled: false },
|
hide: { enabled: false },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span data-testid={testID} data-testclass={testClass} style={style}>
|
{children}
|
||||||
{truncatedString || children}
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user