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