Browse Source

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 years ago
parent
commit
535bd81d61
No account linked to committer's email address

+ 17
- 52
react/features/base/popover/components/Popover.web.js View File

4
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
5
 
5
 
6
 import { Drawer, DrawerPortal } from '../../../toolbox/components/web';
6
 import { Drawer, DrawerPortal } from '../../../toolbox/components/web';
7
-import { isMobileBrowser } from '../../environment/utils';
8
 
7
 
9
 /**
8
 /**
10
  * A map of dialog positions, relative to trigger, to css classes used to
9
  * A map of dialog positions, relative to trigger, to css classes used to
114
         id: ''
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
      * Initializes a new {@code Popover} instance.
117
      * Initializes a new {@code Popover} instance.
124
      *
118
      *
136
         this._onHideDialog = this._onHideDialog.bind(this);
130
         this._onHideDialog = this._onHideDialog.bind(this);
137
         this._onShowDialog = this._onShowDialog.bind(this);
131
         this._onShowDialog = this._onShowDialog.bind(this);
138
         this._onKeyPress = this._onKeyPress.bind(this);
132
         this._onKeyPress = this._onKeyPress.bind(this);
139
-        this._drawerContainerRef = React.createRef();
140
         this._onEscKey = this._onEscKey.bind(this);
133
         this._onEscKey = this._onEscKey.bind(this);
134
+        this._onThumbClick = this._onThumbClick.bind(this);
141
     }
135
     }
142
 
136
 
143
     /**
137
     /**
150
         this.setState({ showDialog: true });
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
      * Implements React's {@link Component#render()}.
148
      * Implements React's {@link Component#render()}.
199
      *
149
      *
208
                 <div
158
                 <div
209
                     className = { className }
159
                     className = { className }
210
                     id = { id }
160
                     id = { id }
211
-                    ref = { this._drawerContainerRef }>
161
+                    onClick = { this._onShowDialog }>
212
                     { children }
162
                     { children }
213
                     <DrawerPortal>
163
                     <DrawerPortal>
214
                         <Drawer
164
                         <Drawer
225
             <div
175
             <div
226
                 className = { className }
176
                 className = { className }
227
                 id = { id }
177
                 id = { id }
178
+                onClick = { this._onThumbClick }
228
                 onKeyPress = { this._onKeyPress }
179
                 onKeyPress = { this._onKeyPress }
229
                 onMouseEnter = { this._onShowDialog }
180
                 onMouseEnter = { this._onShowDialog }
230
                 onMouseLeave = { this._onHideDialog }>
181
                 onMouseLeave = { this._onHideDialog }>
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
     _onKeyPress: (Object) => void;
243
     _onKeyPress: (Object) => void;
279
 
244
 
280
     /**
245
     /**

+ 20
- 1
react/features/toolbox/actions.web.js View File

2
 
2
 
3
 import type { Dispatch } from 'redux';
3
 import type { Dispatch } from 'redux';
4
 
4
 
5
+import { isLayoutTileView } from '../video-layout';
6
+
5
 import {
7
 import {
6
     FULL_SCREEN_CHANGED,
8
     FULL_SCREEN_CHANGED,
7
     SET_FULL_SCREEN,
9
     SET_FULL_SCREEN,
11
     clearToolboxTimeout,
13
     clearToolboxTimeout,
12
     setToolboxTimeout,
14
     setToolboxTimeout,
13
     setToolboxTimeoutMS,
15
     setToolboxTimeoutMS,
14
-    setToolboxVisible
16
+    setToolboxVisible,
17
+    setToolboxEnabled
15
 } from './actions.native';
18
 } from './actions.native';
16
 
19
 
17
 declare var interfaceConfig: Object;
20
 declare var interfaceConfig: Object;
163
         displayAsDrawer
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 View File

32
 /**
32
 /**
33
  * Indicates if the toolbox is visible or not.
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
  * @returns {boolean} - True to indicate that the toolbox is visible, false -
36
  * @returns {boolean} - True to indicate that the toolbox is visible, false -
37
  * otherwise.
37
  * otherwise.
38
  */
38
  */
52
 /**
52
 /**
53
  * Indicates if the audio settings button is disabled or not.
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
  * @returns {boolean}
56
  * @returns {boolean}
57
  */
57
  */
58
 export function isAudioSettingsButtonDisabled(state: Object) {
58
 export function isAudioSettingsButtonDisabled(state: Object) {
64
 /**
64
 /**
65
  * Indicates if the video settings button is disabled or not.
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
  * @returns {boolean}
68
  * @returns {boolean}
69
  */
69
  */
70
 export function isVideoSettingsButtonDisabled(state: Object) {
70
 export function isVideoSettingsButtonDisabled(state: Object) {
74
 /**
74
 /**
75
  * Indicates if the video mute button is disabled or not.
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
  * @returns {boolean}
78
  * @returns {boolean}
79
  */
79
  */
80
 export function isVideoMuteButtonDisabled(state: Object) {
80
 export function isVideoMuteButtonDisabled(state: Object) {
91
 export function showOverflowDrawer(state: Object) {
91
 export function showOverflowDrawer(state: Object) {
92
     return state['features/toolbox'].overflowDrawer;
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 View File

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

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

Loading…
Cancel
Save