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

Commit cd5a1ab

Browse files
authored
Merge pull request #673 from matrix-org/dbkr/make_default_avatars_clickable
Make default avatars clickable
2 parents 8799891 + e7a32fa commit cd5a1ab

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/components/views/avatars/BaseAvatar.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,37 @@ 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>
148+
const textNode = (
149+
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
150+
style={{ fontSize: (width * 0.65) + "px",
151+
width: width + "px",
152+
lineHeight: height + "px" }}
153+
>
154+
{initialLetter}
155+
</EmojiText>
156+
);
157+
const imgNode = (
158+
<img className="mx_BaseAvatar_image" src={imageUrl}
159+
alt="" title={title} onError={this.onError}
160+
width={width} height={height} />
158161
);
162+
if (onClick != null) {
163+
return (
164+
<AccessibleButton element='span' className="mx_BaseAvatar"
165+
onClick={onClick} {...otherProps}
166+
>
167+
{textNode}
168+
{imgNode}
169+
</AccessibleButton>
170+
);
171+
} else {
172+
return (
173+
<span className="mx_BaseAvatar" {...otherProps}>
174+
{textNode}
175+
{imgNode}
176+
</span>
177+
);
178+
}
159179
}
160180
if (onClick != null) {
161181
return (

0 commit comments

Comments
 (0)