Skip to content

Commit

Permalink
Hide web part tile completely when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Mar 2, 2018
1 parent 60aae21 commit 3cfa7ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## 1.2.3

**Enhancements**

- Optimized telemetry so that it only pushes control data
- `WebPartTitle` hide control completely when empty

## 1.2.2

Expand Down
3 changes: 3 additions & 0 deletions docs/documentation/docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## 1.2.3

**Enhancements**

- Optimized telemetry so that it only pushes control data
- `WebPartTitle` hide control completely when empty

## 1.2.2

Expand Down
26 changes: 15 additions & 11 deletions src/controls/webPartTitle/WebPartTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ export class WebPartTitle extends React.Component<IWebPartTitleProps, {}> {
* Default React component render method
*/
public render(): React.ReactElement<IWebPartTitleProps> {
return (
<div className={`${styles.webPartTitle} ${this.props.className ? this.props.className : ''}` }>
{
this.props.displayMode === DisplayMode.Edit && <textarea placeholder={strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} defaultValue={this.props.title}></textarea>
}

{
this.props.displayMode !== DisplayMode.Edit && this.props.title && <span>{this.props.title}</span>
}
</div>
);
if (this.props.title || this.props.displayMode === DisplayMode.Edit) {
return (
<div className={`${styles.webPartTitle} ${this.props.className ? this.props.className : ''}` }>
{
this.props.displayMode === DisplayMode.Edit && <textarea placeholder={strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} defaultValue={this.props.title}></textarea>
}

{
this.props.displayMode !== DisplayMode.Edit && this.props.title && <span>{this.props.title}</span>
}
</div>
);
}

return null;
}
}

0 comments on commit 3cfa7ae

Please sign in to comment.