Make default avatars clickable

BaseAvatar can be passed an onClick which is called when it's, er,
clicked, except when it was the default avatar in which case it
merrily ignored it. Make it not ignore it.
pull/21833/head
David Baker 2017-02-02 18:29:33 +00:00
parent 4ab479594b
commit 7484cc3f70
1 changed files with 27 additions and 11 deletions

View File

@ -145,17 +145,33 @@ module.exports = React.createClass({
if (imageUrl === this.state.defaultImageUrl) { if (imageUrl === this.state.defaultImageUrl) {
const initialLetter = this._getInitialLetter(name); const initialLetter = this._getInitialLetter(name);
return ( if (onClick != null) {
<span className="mx_BaseAvatar" {...otherProps}> return (
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true" <AccessibleButton element='span' className="mx_BaseAvatar"
style={{ fontSize: (width * 0.65) + "px", onClick={onClick} {...otherProps}
width: width + "px", >
lineHeight: height + "px" }}>{initialLetter}</EmojiText> <EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
<img className="mx_BaseAvatar_image" src={imageUrl} style={{ fontSize: (width * 0.65) + "px",
alt="" title={title} onError={this.onError} width: width + "px",
width={width} height={height} /> lineHeight: height + "px" }}>{initialLetter}</EmojiText>
</span> <img className="mx_BaseAvatar_image" src={imageUrl}
); alt="" title={title} onError={this.onError}
width={width} height={height} />
</AccessibleButton>
);
} else {
return (
<span className="mx_BaseAvatar" {...otherProps}>
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
style={{ fontSize: (width * 0.65) + "px",
width: width + "px",
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
<img className="mx_BaseAvatar_image" src={imageUrl}
alt="" title={title} onError={this.onError}
width={width} height={height} />
</span>
);
}
} }
if (onClick != null) { if (onClick != null) {
return ( return (