From 1481dcf9d7ce609200a8d8ff47b0b01dc6bdca19 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 3 Jan 2019 13:57:20 -0700 Subject: [PATCH] Don't re-sort the room list if the user is hovering over it Fixes vector-im/riot-web#5624 --- src/components/views/rooms/RoomList.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index c1cd7e5d57..dbfe95dadf 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -86,6 +86,7 @@ module.exports = React.createClass({ incomingCallTag: null, incomingCall: null, selectedTags: [], + hover: false, }; }, @@ -294,6 +295,17 @@ module.exports = React.createClass({ this.forceUpdate(); }, + onMouseEnter: function(ev) { + this.setState({hover: true}); + }, + + onMouseLeave: function(ev) { + this.setState({hover: false}); + + // Refresh the room list just in case the user missed something. + this._delayedRefreshRoomList(); + }, + _delayedRefreshRoomList: new rate_limited_func(function() { this.refreshRoomList(); }, 500), @@ -346,6 +358,11 @@ module.exports = React.createClass({ }, refreshRoomList: function() { + if (this.state.hover) { + // Don't re-sort the list if we're hovering over the list + return; + } + // TODO: ideally we'd calculate this once at start, and then maintain // any changes to it incrementally, updating the appropriate sublists // as needed. @@ -693,7 +710,8 @@ module.exports = React.createClass({ const subListComponents = this._mapSubListProps(subLists); return ( -
+
{ subListComponents }
);