Fix search clickthrough for HTML events
Switch to using a normal <a href="..."> link for search result clickthrough. Apart from generally giving a better experience, this means that it also works on html messages. The problem there was that we were attaching onClick handlers to <span>s which we were then flattening into HTML with ReactDOMServer (which meant the onClick handlers were never attached to React's list of listeners). To make this work without jumping through React hoops, the highlighter now returns either a list of strings or a list of nodes, depending on whether we are dealing with an HTML event or a text one. We therefore have a separate HtmlHighlighter and TextHighlighter.
This commit is contained in:
parent
38a2a61b38
commit
e3feae32e1
6 changed files with 102 additions and 48 deletions
|
@ -879,15 +879,6 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
_onSearchResultSelected: function(result) {
|
||||
var event = result.context.getEvent();
|
||||
dis.dispatch({
|
||||
action: 'view_room',
|
||||
room_id: event.getRoomId(),
|
||||
event_id: event.getId(),
|
||||
});
|
||||
},
|
||||
|
||||
getSearchResultTiles: function() {
|
||||
var EventTile = sdk.getComponent('rooms.EventTile');
|
||||
var SearchResultTile = sdk.getComponent('rooms.SearchResultTile');
|
||||
|
@ -948,10 +939,12 @@ module.exports = React.createClass({
|
|||
}
|
||||
}
|
||||
|
||||
var resultLink = "#/room/"+this.props.roomId+"/"+mxEv.getId();
|
||||
|
||||
ret.push(<SearchResultTile key={mxEv.getId()}
|
||||
searchResult={result}
|
||||
searchHighlights={this.state.searchHighlights}
|
||||
onSelect={this._onSearchResultSelected.bind(this, result)}/>);
|
||||
resultLink={resultLink}/>);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue