diff --git a/src/components/views/rooms/EntityTile.js b/src/components/views/rooms/EntityTile.js
index 009da0ebd4..e99f0a6746 100644
--- a/src/components/views/rooms/EntityTile.js
+++ b/src/components/views/rooms/EntityTile.js
@@ -92,17 +92,31 @@ const EntityTile = React.createClass({
};
},
+ componentWillMount: function() {
+ // We use a listener on the document so we can find out when the cursor leaves the element more
+ // safely. This is a workaround for https://github.com/facebook/react/issues/4492 and
+ // https://github.com/vector-im/riot-web/issues/1997
+ document.addEventListener("mouseover", this.mouseEnter);
+ },
+
+ componentWillUnmount: function() {
+ document.removeEventListener("mouseover", this.mouseEnter);
+ },
+
shouldComponentUpdate: function(nextProps, nextState) {
if (this.state.hover !== nextState.hover) return true;
return this.props.shouldComponentUpdate(nextProps, nextState);
},
- mouseEnter: function(e) {
- this.setState({ 'hover': true });
- },
+ mouseEnter: function(ev) {
+ let targetHover = false;
+ if (this.container && (this.container === ev.target || this.container.contains(ev.target))) {
+ targetHover = true;
+ }
- mouseLeave: function(e) {
- this.setState({ 'hover': false });
+ if (targetHover !== this.state.hover) {
+ this.setState({hover: targetHover});
+ }
},
render: function() {
@@ -183,17 +197,18 @@ const EntityTile = React.createClass({
const av = this.props.avatarJsx ||