From e059a08d7be32bd0d4df624cd354075bbb0cd0c5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 27 Jul 2018 18:53:36 +0100 Subject: [PATCH 1/2] Make clicking on side panels close settings (mk 3) Just do it by fixing the somewhat hacky logic to not break if the target elements also have additional classes, like they do if the toolbar is showing (I think it turns out this bug is only that it doesn't work with the toolbar showing...) Fixes https://github.com/vector-im/riot-web/issues/5658 --- src/components/structures/LoggedInView.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 5dca359f32..a8ef8adbcc 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -259,12 +259,13 @@ const LoggedInView = React.createClass({ // When the panels are disabled, clicking on them results in a mouse event // which bubbles to certain elements in the tree. When this happens, close // any settings page that is currently open (user/room/group). + const targetClasses = new Set(ev.target.className.split(' ')); if (this.props.leftDisabled && this.props.rightDisabled && ( - ev.target.className === 'mx_MatrixChat' || - ev.target.className === 'mx_MatrixChat_middlePanel' || - ev.target.className === 'mx_RoomView' + targetClasses.has('mx_MatrixChat') || + targetClasses.has('mx_MatrixChat_middlePanel') || + targetClasses.has('mx_RoomView') ) ) { dis.dispatch({ action: 'close_settings' }); From f4c073ad45615a64f8d4fa935b893f1a2484cc8a Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 27 Jul 2018 18:58:11 +0100 Subject: [PATCH 2/2] Nest ifs to avoid unnecessary work --- src/components/structures/LoggedInView.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index a8ef8adbcc..de35e41086 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -259,16 +259,15 @@ const LoggedInView = React.createClass({ // When the panels are disabled, clicking on them results in a mouse event // which bubbles to certain elements in the tree. When this happens, close // any settings page that is currently open (user/room/group). - const targetClasses = new Set(ev.target.className.split(' ')); - if (this.props.leftDisabled && - this.props.rightDisabled && - ( + if (this.props.leftDisabled && this.props.rightDisabled) { + const targetClasses = new Set(ev.target.className.split(' ')); + if ( targetClasses.has('mx_MatrixChat') || targetClasses.has('mx_MatrixChat_middlePanel') || targetClasses.has('mx_RoomView') - ) - ) { - dis.dispatch({ action: 'close_settings' }); + ) { + dis.dispatch({ action: 'close_settings' }); + } } },