Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7484cc3

Browse files
committed
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.
1 parent 4ab4795 commit 7484cc3

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/components/views/avatars/BaseAvatar.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,33 @@ module.exports = React.createClass({
145145

146146
if (imageUrl === this.state.defaultImageUrl) {
147147
const initialLetter = this._getInitialLetter(name);
148-
return (
149-
<span className="mx_BaseAvatar" {...otherProps}>
150-
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
151-
style={{ fontSize: (width * 0.65) + "px",
152-
width: width + "px",
153-
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
154-
<img className="mx_BaseAvatar_image" src={imageUrl}
155-
alt="" title={title} onError={this.onError}
156-
width={width} height={height} />
157-
</span>
158-
);
148+
if (onClick != null) {
149+
return (
150+
<AccessibleButton element='span' className="mx_BaseAvatar"
151+
onClick={onClick} {...otherProps}
152+
>
153+
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
154+
style={{ fontSize: (width * 0.65) + "px",
155+
width: width + "px",
156+
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
157+
<img className="mx_BaseAvatar_image" src={imageUrl}
158+
alt="" title={title} onError={this.onError}
159+
width={width} height={height} />
160+
</AccessibleButton>
161+
);
162+
} else {
163+
return (
164+
<span className="mx_BaseAvatar" {...otherProps}>
165+
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
166+
style={{ fontSize: (width * 0.65) + "px",
167+
width: width + "px",
168+
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
169+
<img className="mx_BaseAvatar_image" src={imageUrl}
170+
alt="" title={title} onError={this.onError}
171+
width={width} height={height} />
172+
</span>
173+
);
174+
}
159175
}
160176
if (onClick != null) {
161177
return (

0 commit comments

Comments
 (0)