Skip to content

Commit

Permalink
fix: fix text ellipsis showing popover all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
lightbringer1991 committed Jun 16, 2021
1 parent 688e6c1 commit 78fe942
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/components/TextEllipsis/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class TextEllipsisComponent extends React.PureComponent {
truncated: false,
};

componentDidMount() {
this.setTruncate();
}

componentDidUpdate() {
this.setTruncate();
}
Expand All @@ -50,7 +54,7 @@ class TextEllipsisComponent extends React.PureComponent {
return (
<Popover
{...popoverProps}
isOpen={truncated}
{...(truncated === false ? { triggers: 'disabled' } : {})}
popoverContent={this.props.children}
className="aui--text-ellipsis-wrapper"
>
Expand Down
21 changes: 15 additions & 6 deletions www/examples/TextEllipsis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import DesignNotes from '../containers/DesignNotes.jsx';
## Text Ellipsis

```jsx live=true
<div style={{ width: 300 }}>
<TextEllipsis>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</TextEllipsis>
<div>
<div style={{ width: 500 }}>
<TextEllipsis>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</TextEllipsis>
</div>

<br />
<br />

<div style={{ width: 500 }}>
<TextEllipsis>no popover for short text</TextEllipsis>
</div>
</div>
```

Expand Down

0 comments on commit 78fe942

Please sign in to comment.