From 4c05edb71be15923ebc45d3b971dd9306f2abd97 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Fri, 2 Sep 2016 15:47:40 +0100 Subject: [PATCH] Refactor of the RoomTooltip, so that it is easier to use, and also works with Safari --- src/components/views/rooms/RoomList.js | 9 ++++----- src/components/views/rooms/RoomTile.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 206bf8504e..98fcb92b06 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -77,6 +77,7 @@ module.exports = React.createClass({ switch (payload.action) { case 'view_tooltip': this.tooltip = payload.tooltip; + this.tooltipParent = payload.parent; this._repositionTooltip(); if (this.tooltip) this.tooltip.style.display = 'block'; break; @@ -275,11 +276,9 @@ module.exports = React.createClass({ }, _repositionTooltip: function(e) { - // We access the parent of the parent, as the tooltip is inside a container - // Needs refactoring into a better multipurpose tooltip - if (this.tooltip && this.tooltip.parentElement && this.tooltip.parentElement.parentElement) { - var scroll = ReactDOM.findDOMNode(this); - this.tooltip.style.top = (3 + scroll.parentElement.offsetTop + this.tooltip.parentElement.parentElement.offsetTop - this._getScrollNode().scrollTop) + "px"; + if (this.tooltip && this.tooltipParent) { + this.tooltip.style.top = this.tooltipParent.getBoundingClientRect().top + "px"; + this.tooltip.style.left = this.tooltipParent.getBoundingClientRect().right + "px"; } }, diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index b646b12e76..de0735f755 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -248,7 +248,7 @@ module.exports = React.createClass({ } else if (this.state.hover) { var RoomTooltip = sdk.getComponent("rooms.RoomTooltip"); - label = ; + label = ; } var incomingCallBox;