Tweak of the RoomTooltip to use DOM element for the parent rather than a React component

This commit is contained in:
wmwragg 2016-09-02 18:41:27 +01:00
parent d2e2c726eb
commit bf4e3364b4
1 changed files with 11 additions and 8 deletions

View File

@ -25,7 +25,7 @@ module.exports = React.createClass({
displayName: 'RoomTooltip',
propTypes: {
component: React.PropTypes.object.isRequired,
parent: React.PropTypes.object.isRequired,
room: React.PropTypes.object,
label: React.PropTypes.string,
},
@ -36,14 +36,17 @@ module.exports = React.createClass({
this.tooltipContainer.className = "mx_RoomTileTooltip_wrapper";
document.body.appendChild(this.tooltipContainer);
this._renderTooltip();
// don't render tooltip if parent is undefined
if (this.props.parent) {
this._renderTooltip();
// tell the roomlist about us so it can position us
dis.dispatch({
action: 'view_tooltip',
tooltip: this.tooltip,
parent: this.props.component ? ReactDOM.findDOMNode(this.props.component) : null,
});
// tell the roomlist about us so it can position us
dis.dispatch({
action: 'view_tooltip',
tooltip: this.tooltip,
parent: this.props.parent,
});
}
},
// Remove the wrapper element, as the tooltip has finished using it