From 5417385c83f38492861d17abfd8e7a41c12a126b Mon Sep 17 00:00:00 2001 From: wmwragg Date: Sun, 4 Sep 2016 07:41:48 +0100 Subject: [PATCH] Tolltip thweak to not require the passing in of the parent --- src/components/structures/BottomLeftMenu.js | 16 ++++++++-------- src/components/views/rooms/RoomTooltip.js | 13 +------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/components/structures/BottomLeftMenu.js b/src/components/structures/BottomLeftMenu.js index 6858a47dfb..178fe94082 100644 --- a/src/components/structures/BottomLeftMenu.js +++ b/src/components/structures/BottomLeftMenu.js @@ -76,10 +76,10 @@ module.exports = React.createClass({ }, // Get the label/tooltip to show - getLabel: function(label, parent, show) { + getLabel: function(label, show) { if (show) { var RoomTooltip = sdk.getComponent("rooms.RoomTooltip"); - return ; + return ; } }, @@ -88,17 +88,17 @@ module.exports = React.createClass({ return (
-
this._rooms = ref} > +
- { this.getLabel("Rooms", this._rooms, this.state.roomsHover) } + { this.getLabel("Rooms", this.state.roomsHover) }
-
this._people = ref} > +
- { this.getLabel("New direct message", this._people, this.state.peopleHover) } + { this.getLabel("New direct message", this.state.peopleHover) }
-
this._settings = ref} > +
- { this.getLabel("Settings", this._settings, this.state.settingsHover) } + { this.getLabel("Settings", this.state.settingsHover) }
diff --git a/src/components/views/rooms/RoomTooltip.js b/src/components/views/rooms/RoomTooltip.js index e2cdd8a226..ce0b0f6198 100644 --- a/src/components/views/rooms/RoomTooltip.js +++ b/src/components/views/rooms/RoomTooltip.js @@ -25,9 +25,6 @@ module.exports = React.createClass({ displayName: 'RoomTooltip', propTypes: { - // The 'parent' can either be a React component or a DOM element - parent: React.PropTypes.object.isRequired, - // The tooltip is derived from either the room name or a label room: React.PropTypes.object, label: React.PropTypes.string, @@ -83,19 +80,11 @@ module.exports = React.createClass({ if (this.props.left) { style.left = this.props.left; } if (this.props.right) { style.right = this.props.right; } - var parent; - if (this._isDOMElement(this.props.parent)) { - parent = this.props.parent; - } else if (this._isReactComponent(this.props.parent)) { - parent = ReactDOM.findDOMNode(this.props.parent); - } else { - parent = null; - } - // If a parent exists, add the parent's position to the tooltips, so it's correctly // positioned, also taking into account any window zoom // NOTE: The additional 6 pixels for the left position, is to take account of the // tooltips chevron + var parent = ReactDOM.findDOMNode(this).parentElement; if (parent) { style.top = (+style.top || 0) + parent.getBoundingClientRect().top + window.pageYOffset; style.left = (+style.left || 0) + 6 + parent.getBoundingClientRect().right + window.pageXOffset;