Skip to content

Commit

Permalink
PageHeader: Remove tooltip from default since title is present (#3099)
Browse files Browse the repository at this point in the history
  • Loading branch information
interactivellama authored Feb 23, 2023
1 parent 1e609b4 commit f59d1b2
Showing 1 changed file with 1 addition and 48 deletions.
49 changes: 1 addition & 48 deletions components/page-header/private/detail-block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Tooltip from '../../tooltip';

const displayName = 'PageHeaderDetailRow';
const propTypes = {
Expand Down Expand Up @@ -43,21 +42,6 @@ const defaultProps = {
};

class DetailBlock extends Component {
constructor(props) {
super(props);
this.state = { showTooltip: false };
}

componentDidMount() {
this.renderFieldTruncation();
}

componentDidUpdate(prevProps) {
if (this.props.content !== prevProps.content) {
this.renderFieldTruncation();
}
}

renderContent() {
const { content, truncate } = this.props;

Expand All @@ -80,35 +64,6 @@ class DetailBlock extends Component {
return content;
}

renderContentWithTooltip() {
const { content, truncate } = this.props;
const labelClasses = classnames({ 'slds-truncate': truncate });

return (
<Tooltip
align="top"
content={content}
triggerStyle={{ display: 'inline' }}
>
<div className={labelClasses} tabIndex="0" title={content}>
{content}
</div>
</Tooltip>
);
}

renderFieldTruncation() {
const fieldContent = this.fieldContentRef;
const isTruncated =
fieldContent && fieldContent.scrollWidth > fieldContent.offsetWidth;

if (isTruncated) {
this.setState({ showTooltip: true });
} else {
this.setState({ showTooltip: false });
}
}

renderLabel() {
const { label, truncate } = this.props;

Expand Down Expand Up @@ -137,9 +92,7 @@ class DetailBlock extends Component {
return (
<li className={classes}>
{this.renderLabel()}
{this.state.showTooltip
? this.renderContentWithTooltip()
: this.renderContent()}
{this.renderContent()}
</li>
);
}
Expand Down

0 comments on commit f59d1b2

Please sign in to comment.