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

Commit 6baca05

Browse files
authored
Merge pull request #1297 from matrix-org/luke/fix-user-pill-onclick
Add onClick to user pills 
2 parents 7d10a75 + 5eff2a3 commit 6baca05

File tree

1 file changed

+12
-1
lines changed
  • src/components/views/elements

1 file changed

+12
-1
lines changed

src/components/views/elements/Pill.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616
import React from 'react';
1717
import sdk from '../../../index';
18+
import dis from '../../../dispatcher';
1819
import classNames from 'classnames';
1920
import { Room, RoomMember } from 'matrix-js-sdk';
2021
import PropTypes from 'prop-types';
@@ -140,6 +141,12 @@ const Pill = React.createClass({
140141
});
141142
},
142143

144+
onUserPillClicked: function() {
145+
dis.dispatch({
146+
action: 'view_user',
147+
member: this.state.member,
148+
});
149+
},
143150
render: function() {
144151
const MemberAvatar = sdk.getComponent('avatars.MemberAvatar');
145152
const RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
@@ -150,6 +157,8 @@ const Pill = React.createClass({
150157
let linkText = resource;
151158
let pillClass;
152159
let userId;
160+
let href = this.props.url;
161+
let onClick;
153162
switch (this.state.pillType) {
154163
case Pill.TYPE_USER_MENTION: {
155164
// If this user is not a member of this room, default to the empty member
@@ -161,6 +170,8 @@ const Pill = React.createClass({
161170
avatar = <MemberAvatar member={member} width={16} height={16}/>;
162171
}
163172
pillClass = 'mx_UserPill';
173+
href = null;
174+
onClick = this.onUserPillClicked.bind(this);
164175
}
165176
}
166177
break;
@@ -183,7 +194,7 @@ const Pill = React.createClass({
183194

184195
if (this.state.pillType) {
185196
return this.props.inMessage ?
186-
<a className={classes} href={this.props.url} title={resource} data-offset-key={this.props.offsetKey}>
197+
<a className={classes} href={href} onClick={onClick} title={resource} data-offset-key={this.props.offsetKey}>
187198
{avatar}
188199
{linkText}
189200
</a> :

0 commit comments

Comments
 (0)