Selaa lähdekoodia

fix(context-menu) Hide toolbars when participant context menu opened (#9842)

- hide toolbars only when in tile view
- fix community issue: https://github.com/jitsi/jitsi-meet/issues/9818
master
Horatiu Muresan 4 vuotta sitten
vanhempi
commit
535bd81d61
No account linked to committer's email address

+ 17
- 52
react/features/base/popover/components/Popover.web.js Näytä tiedosto

@@ -4,7 +4,6 @@ import InlineDialog from '@atlaskit/inline-dialog';
4 4
 import React, { Component } from 'react';
5 5
 
6 6
 import { Drawer, DrawerPortal } from '../../../toolbox/components/web';
7
-import { isMobileBrowser } from '../../environment/utils';
8 7
 
9 8
 /**
10 9
  * A map of dialog positions, relative to trigger, to css classes used to
@@ -114,11 +113,6 @@ class Popover extends Component<Props, State> {
114 113
         id: ''
115 114
     };
116 115
 
117
-    /**
118
-     * Reference to the Popover that is meant to open as a drawer.
119
-     */
120
-    _drawerContainerRef: Object;
121
-
122 116
     /**
123 117
      * Initializes a new {@code Popover} instance.
124 118
      *
@@ -136,8 +130,8 @@ class Popover extends Component<Props, State> {
136 130
         this._onHideDialog = this._onHideDialog.bind(this);
137 131
         this._onShowDialog = this._onShowDialog.bind(this);
138 132
         this._onKeyPress = this._onKeyPress.bind(this);
139
-        this._drawerContainerRef = React.createRef();
140 133
         this._onEscKey = this._onEscKey.bind(this);
134
+        this._onThumbClick = this._onThumbClick.bind(this);
141 135
     }
142 136
 
143 137
     /**
@@ -150,50 +144,6 @@ class Popover extends Component<Props, State> {
150 144
         this.setState({ showDialog: true });
151 145
     }
152 146
 
153
-    /**
154
-     * Sets up an event listener to open a drawer when clicking, rather than entering the
155
-     * overflow area.
156
-     *
157
-     * TODO: This should be done by setting an {@code onClick} handler on the div, but for some
158
-     * reason that doesn't seem to work whatsoever.
159
-     *
160
-     * @inheritdoc
161
-     * @returns {void}
162
-     */
163
-    componentDidMount() {
164
-        if (this._drawerContainerRef && this._drawerContainerRef.current && !isMobileBrowser()) {
165
-            this._drawerContainerRef.current.addEventListener('click', this._onShowDialog);
166
-        }
167
-    }
168
-
169
-    /**
170
-     * Removes the listener set up in the {@code componentDidMount} method.
171
-     *
172
-     * @inheritdoc
173
-     * @returns {void}
174
-     */
175
-    componentWillUnmount() {
176
-        if (this._drawerContainerRef && this._drawerContainerRef.current) {
177
-            this._drawerContainerRef.current.removeEventListener('click', this._onShowDialog);
178
-        }
179
-    }
180
-
181
-    /**
182
-     * Implements React Component's componentDidUpdate.
183
-     *
184
-     * @inheritdoc
185
-     */
186
-    componentDidUpdate(prevProps: Props) {
187
-        if (prevProps.overflowDrawer !== this.props.overflowDrawer) {
188
-            // Make sure the listeners are set up when resizing the screen past the drawer threshold.
189
-            if (this.props.overflowDrawer) {
190
-                this.componentDidMount();
191
-            } else {
192
-                this.componentWillUnmount();
193
-            }
194
-        }
195
-    }
196
-
197 147
     /**
198 148
      * Implements React's {@link Component#render()}.
199 149
      *
@@ -208,7 +158,7 @@ class Popover extends Component<Props, State> {
208 158
                 <div
209 159
                     className = { className }
210 160
                     id = { id }
211
-                    ref = { this._drawerContainerRef }>
161
+                    onClick = { this._onShowDialog }>
212 162
                     { children }
213 163
                     <DrawerPortal>
214 164
                         <Drawer
@@ -225,6 +175,7 @@ class Popover extends Component<Props, State> {
225 175
             <div
226 176
                 className = { className }
227 177
                 id = { id }
178
+                onClick = { this._onThumbClick }
228 179
                 onKeyPress = { this._onKeyPress }
229 180
                 onMouseEnter = { this._onShowDialog }
230 181
                 onMouseLeave = { this._onHideDialog }>
@@ -275,6 +226,20 @@ class Popover extends Component<Props, State> {
275 226
         }
276 227
     }
277 228
 
229
+    _onThumbClick: (Object) => void;
230
+
231
+    /**
232
+     * Prevents switching from tile view to stage view on accidentally clicking
233
+     * the popover thumbs.
234
+     *
235
+     * @param {Object} event - The mouse event or the keypress event to intercept.
236
+     * @private
237
+     * @returns {void}
238
+     */
239
+    _onThumbClick(event) {
240
+        event.stopPropagation();
241
+    }
242
+
278 243
     _onKeyPress: (Object) => void;
279 244
 
280 245
     /**

+ 20
- 1
react/features/toolbox/actions.web.js Näytä tiedosto

@@ -2,6 +2,8 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
+import { isLayoutTileView } from '../video-layout';
6
+
5 7
 import {
6 8
     FULL_SCREEN_CHANGED,
7 9
     SET_FULL_SCREEN,
@@ -11,7 +13,8 @@ import {
11 13
     clearToolboxTimeout,
12 14
     setToolboxTimeout,
13 15
     setToolboxTimeoutMS,
14
-    setToolboxVisible
16
+    setToolboxVisible,
17
+    setToolboxEnabled
15 18
 } from './actions.native';
16 19
 
17 20
 declare var interfaceConfig: Object;
@@ -163,3 +166,19 @@ export function setOverflowDrawer(displayAsDrawer: boolean) {
163 166
         displayAsDrawer
164 167
     };
165 168
 }
169
+
170
+/**
171
+ * Disables and hides the toolbox on demand when in tile view.
172
+ *
173
+ * @returns {void}
174
+ */
175
+export function disableToolboxOnTileView() {
176
+    return (dispatch: Dispatch<any>, getState: Function) => {
177
+        if (!isLayoutTileView(getState())) {
178
+            return;
179
+        }
180
+
181
+        dispatch(setToolboxEnabled(false));
182
+        dispatch(hideToolbox(true));
183
+    };
184
+}

+ 14
- 4
react/features/toolbox/functions.web.js Näytä tiedosto

@@ -32,7 +32,7 @@ export function isButtonEnabled(name: string, state: Object) {
32 32
 /**
33 33
  * Indicates if the toolbox is visible or not.
34 34
  *
35
- * @param {string} state - The state from the Redux store.
35
+ * @param {Object} state - The state from the Redux store.
36 36
  * @returns {boolean} - True to indicate that the toolbox is visible, false -
37 37
  * otherwise.
38 38
  */
@@ -52,7 +52,7 @@ export function isToolboxVisible(state: Object) {
52 52
 /**
53 53
  * Indicates if the audio settings button is disabled or not.
54 54
  *
55
- * @param {string} state - The state from the Redux store.
55
+ * @param {Object} state - The state from the Redux store.
56 56
  * @returns {boolean}
57 57
  */
58 58
 export function isAudioSettingsButtonDisabled(state: Object) {
@@ -64,7 +64,7 @@ export function isAudioSettingsButtonDisabled(state: Object) {
64 64
 /**
65 65
  * Indicates if the video settings button is disabled or not.
66 66
  *
67
- * @param {string} state - The state from the Redux store.
67
+ * @param {Object} state - The state from the Redux store.
68 68
  * @returns {boolean}
69 69
  */
70 70
 export function isVideoSettingsButtonDisabled(state: Object) {
@@ -74,7 +74,7 @@ export function isVideoSettingsButtonDisabled(state: Object) {
74 74
 /**
75 75
  * Indicates if the video mute button is disabled or not.
76 76
  *
77
- * @param {string} state - The state from the Redux store.
77
+ * @param {Object} state - The state from the Redux store.
78 78
  * @returns {boolean}
79 79
  */
80 80
 export function isVideoMuteButtonDisabled(state: Object) {
@@ -91,3 +91,13 @@ export function isVideoMuteButtonDisabled(state: Object) {
91 91
 export function showOverflowDrawer(state: Object) {
92 92
     return state['features/toolbox'].overflowDrawer;
93 93
 }
94
+
95
+/**
96
+ * Indicates whether the toolbox is enabled or not.
97
+ *
98
+ * @param {Object} state - The state from the Redux store.
99
+ * @returns {boolean}
100
+ */
101
+export function isToolboxEnabled(state: Object) {
102
+    return state['features/toolbox'].enabled;
103
+}

+ 31
- 1
react/features/video-menu/components/web/LocalVideoMenuTriggerButton.js Näytä tiedosto

@@ -12,6 +12,8 @@ import { Popover } from '../../../base/popover';
12 12
 import { connect } from '../../../base/redux';
13 13
 import { getLocalVideoTrack } from '../../../base/tracks';
14 14
 import ConnectionIndicatorContent from '../../../connection-indicator/components/web/ConnectionIndicatorContent';
15
+import { setToolboxEnabled, disableToolboxOnTileView } from '../../../toolbox/actions';
16
+import { isToolboxEnabled } from '../../../toolbox/functions';
15 17
 import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
16 18
 import { renderConnectionStatus } from '../../actions.web';
17 19
 
@@ -63,6 +65,11 @@ type Props = {
63 65
      */
64 66
     _showLocalVideoFlipButton: boolean,
65 67
 
68
+    /**
69
+     * Whether the toolbox is enabled or not.
70
+     */
71
+    _toolboxEnabled: boolean,
72
+
66 73
     /**
67 74
      * Invoked to obtain translated strings.
68 75
      */
@@ -76,6 +83,11 @@ type Props = {
76 83
  * @extends {Component}
77 84
  */
78 85
 class LocalVideoMenuTriggerButton extends Component<Props> {
86
+    /**
87
+     * Preserve the intial toolbox state.
88
+     */
89
+     initialToolboxEnabled: boolean;
90
+
79 91
     /**
80 92
      * Reference to the Popover instance.
81 93
      */
@@ -91,7 +103,9 @@ class LocalVideoMenuTriggerButton extends Component<Props> {
91 103
         super(props);
92 104
 
93 105
         this.popoverRef = React.createRef();
106
+        this.initialToolboxEnabled = true;
94 107
         this._onPopoverClose = this._onPopoverClose.bind(this);
108
+        this._onPopoverOpen = this._onPopoverOpen.bind(this);
95 109
     }
96 110
 
97 111
     /**
@@ -115,6 +129,8 @@ class LocalVideoMenuTriggerButton extends Component<Props> {
115 129
         if (this.props.getRef) {
116 130
             this.props.getRef(this);
117 131
         }
132
+
133
+        this.initialToolboxEnabled = this.props._toolboxEnabled;
118 134
     }
119 135
 
120 136
     /**
@@ -161,6 +177,7 @@ class LocalVideoMenuTriggerButton extends Component<Props> {
161 177
                 ? <Popover
162 178
                     content = { content }
163 179
                     onPopoverClose = { this._onPopoverClose }
180
+                    onPopoverOpen = { this._onPopoverOpen }
164 181
                     overflowDrawer = { _overflowDrawer }
165 182
                     position = { _menuPosition }
166 183
                     ref = { this.popoverRef }>
@@ -181,6 +198,17 @@ class LocalVideoMenuTriggerButton extends Component<Props> {
181 198
         );
182 199
     }
183 200
 
201
+    _onPopoverOpen: () => void;
202
+
203
+    /**
204
+     * Disable and hide toolbox while context menu is open.
205
+     *
206
+     * @returns {void}
207
+     */
208
+    _onPopoverOpen() {
209
+        this.props.dispatch(disableToolboxOnTileView());
210
+    }
211
+
184 212
     _onPopoverClose: () => void;
185 213
 
186 214
     /**
@@ -189,6 +217,7 @@ class LocalVideoMenuTriggerButton extends Component<Props> {
189 217
      * @returns {void}
190 218
      */
191 219
     _onPopoverClose() {
220
+        this.props.dispatch(setToolboxEnabled(this.initialToolboxEnabled));
192 221
         this.props.dispatch(renderConnectionStatus(false));
193 222
     }
194 223
 }
@@ -229,7 +258,8 @@ function _mapStateToProps(state) {
229 258
         _showLocalVideoFlipButton: !disableLocalVideoFlip && videoTrack?.videoType !== 'desktop',
230 259
         _overflowDrawer: overflowDrawer,
231 260
         _localParticipantId: localParticipant.id,
232
-        _showConnectionInfo: showConnectionInfo
261
+        _showConnectionInfo: showConnectionInfo,
262
+        _toolboxEnabled: isToolboxEnabled(state)
233 263
     };
234 264
 }
235 265
 

+ 31
- 1
react/features/video-menu/components/web/RemoteVideoMenuTriggerButton.js Näytä tiedosto

@@ -11,6 +11,8 @@ import { getLocalParticipant, getParticipantById, PARTICIPANT_ROLE } from '../..
11 11
 import { Popover } from '../../../base/popover';
12 12
 import { connect } from '../../../base/redux';
13 13
 import { requestRemoteControl, stopController } from '../../../remote-control';
14
+import { setToolboxEnabled, disableToolboxOnTileView } from '../../../toolbox/actions';
15
+import { isToolboxEnabled } from '../../../toolbox/functions';
14 16
 import { getCurrentLayout, LAYOUTS } from '../../../video-layout';
15 17
 import { renderConnectionStatus } from '../../actions.web';
16 18
 
@@ -76,6 +78,11 @@ type Props = {
76 78
      */
77 79
     _remoteControlState: number,
78 80
 
81
+    /**
82
+     * Whether the toolbox is enabled or not.
83
+     */
84
+    _toolboxEnabled: boolean,
85
+
79 86
     /**
80 87
      * The redux dispatch function.
81 88
      */
@@ -126,6 +133,11 @@ type Props = {
126 133
  * @extends {Component}
127 134
  */
128 135
 class RemoteVideoMenuTriggerButton extends Component<Props> {
136
+    /**
137
+     * Preserve the intial toolbox state.
138
+     */
139
+     initialToolboxEnabled: boolean;
140
+
129 141
     /**
130 142
      * Reference to the Popover instance.
131 143
      */
@@ -141,7 +153,9 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
141 153
         super(props);
142 154
 
143 155
         this.popoverRef = React.createRef();
156
+        this.initialToolboxEnabled = true;
144 157
         this._onPopoverClose = this._onPopoverClose.bind(this);
158
+        this._onPopoverOpen = this._onPopoverOpen.bind(this);
145 159
     }
146 160
 
147 161
     /**
@@ -165,6 +179,8 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
165 179
         if (this.props.getRef) {
166 180
             this.props.getRef(this);
167 181
         }
182
+
183
+        this.initialToolboxEnabled = this.props._toolboxEnabled;
168 184
     }
169 185
 
170 186
     /**
@@ -201,6 +217,7 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
201 217
             <Popover
202 218
                 content = { content }
203 219
                 onPopoverClose = { this._onPopoverClose }
220
+                onPopoverOpen = { this._onPopoverOpen }
204 221
                 overflowDrawer = { this.props._overflowDrawer }
205 222
                 position = { this.props._menuPosition }
206 223
                 ref = { this.popoverRef }>
@@ -219,6 +236,17 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
219 236
         );
220 237
     }
221 238
 
239
+    _onPopoverOpen: () => void;
240
+
241
+    /**
242
+     * Disable and hide toolbox while context menu is open.
243
+     *
244
+     * @returns {void}
245
+     */
246
+    _onPopoverOpen() {
247
+        this.props.dispatch(disableToolboxOnTileView());
248
+    }
249
+
222 250
     _onPopoverClose: () => void;
223 251
 
224 252
     /**
@@ -227,6 +255,7 @@ class RemoteVideoMenuTriggerButton extends Component<Props> {
227 255
      * @returns {void}
228 256
      */
229 257
     _onPopoverClose() {
258
+        this.props.dispatch(setToolboxEnabled(this.initialToolboxEnabled));
230 259
         this.props.dispatch(renderConnectionStatus(false));
231 260
     }
232 261
 
@@ -406,7 +435,8 @@ function _mapStateToProps(state, ownProps) {
406 435
         _overflowDrawer: overflowDrawer,
407 436
         _participantDisplayName,
408 437
         _disableGrantModerator: Boolean(disableGrantModerator),
409
-        _showConnectionInfo: showConnectionInfo
438
+        _showConnectionInfo: showConnectionInfo,
439
+        _toolboxEnabled: isToolboxEnabled(state)
410 440
     };
411 441
 }
412 442
 

Loading…
Peruuta
Tallenna