Skip to content

Commit

Permalink
MM-10602 Removed extra space from OpenGraph preview for links without…
Browse files Browse the repository at this point in the history
… a description (mattermost#1276)

* MM-10602 Removed extra space from OpenGraph preview for links without a description

* Removed unnecessary div
  • Loading branch information
hmhealey authored and cpanato committed Jun 7, 2018
1 parent c73fb23 commit a567618
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
img.src = src;
}

imageToggleAnchoreTag(imageUrl) {
imageToggleAnchorTag(imageUrl) {
if (imageUrl && this.state.hasLargeImage) {
return (
<a
Expand Down Expand Up @@ -282,6 +282,29 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
this.loadImage(imageUrl);
}

let body;
if (data.description || imageUrl) {
let separator;
if (data.description && imageUrl) {
separator = ' &nbsp';
}

body = (
<React.Fragment>
<div className={'attachment__body attachment__body--opengraph'}>
<div>
<div>
{this.truncateText(data.description)}
{separator}
{this.imageToggleAnchorTag(imageUrl)}
</div>
{this.imageTag(imageUrl, true)}
</div>
</div>
</React.Fragment>
);
}

return (
<div
className='attachment attachment--opengraph'
Expand Down Expand Up @@ -309,19 +332,7 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
{this.truncateText(data.title || data.url || this.props.link)}
</a>
</h1>
<div >
<div
className={'attachment__body attachment__body--opengraph'}
>
<div>
<div>
{this.truncateText(data.description)} &nbsp;
{this.imageToggleAnchoreTag(imageUrl)}
</div>
{this.imageTag(imageUrl, true)}
</div>
</div>
</div>
{body}
</div>
{this.imageTag(imageUrl, false)}
</div>
Expand Down

0 comments on commit a567618

Please sign in to comment.