Browse Source

fix(device-selection): do not create a dropdown menu if disabled

AtlasKit DropdownMenu cannot be disabled, unlike Single Select.
The result is the isDisabled prop was not being honored. The
workaround is returning only the trigger element for the dropdown
and styling it to look like the dropdown is disabled. The text
for disabled device selection was changed along the way to fit
into the trigger.
master
Leonard Kim 8 years ago
parent
commit
4e95dbf0e5

+ 6
- 0
css/modals/device-selection/_device-selection.scss View File

36
                 background-color: rgba(9,30,66,.08);
36
                 background-color: rgba(9,30,66,.08);
37
             }
37
             }
38
         }
38
         }
39
+        .device-selector-trigger-disabled {
40
+            .device-selector-trigger {
41
+                color: #a5adba;
42
+                cursor: default;
43
+            }
44
+        }
39
 
45
 
40
         .device-selector-trigger-text {
46
         .device-selector-trigger-text {
41
             overflow: hidden;
47
             overflow: hidden;

+ 1
- 2
lang/main.json View File

149
         "selectAudioOutput": "Audio output",
149
         "selectAudioOutput": "Audio output",
150
         "followMe": "Everyone follows me",
150
         "followMe": "Everyone follows me",
151
         "noDevice": "None",
151
         "noDevice": "None",
152
-        "noPermission": "Permission to use device is not granted",
153
         "cameraAndMic": "Camera and microphone",
152
         "cameraAndMic": "Camera and microphone",
154
         "moderator": "MODERATOR",
153
         "moderator": "MODERATOR",
155
         "password": "SET PASSWORD",
154
         "password": "SET PASSWORD",
423
     "deviceSelection": {
422
     "deviceSelection": {
424
         "currentlyVideoMuted": "Video is currently muted",
423
         "currentlyVideoMuted": "Video is currently muted",
425
         "deviceSettings": "Device settings",
424
         "deviceSettings": "Device settings",
426
-        "noOtherDevices": "No other devices available",
425
+        "noPermission": "Permission not granted",
427
         "selectADevice": "Select a device",
426
         "selectADevice": "Select a device",
428
         "testAudio": "Test sound"
427
         "testAudio": "Test sound"
429
     },
428
     },

+ 16
- 8
react/features/device-selection/components/DeviceSelector.js View File

138
     }
138
     }
139
 
139
 
140
     /**
140
     /**
141
-     * Creates a AKDropdownMenu Component using passed in props and options.
141
+     * Creates a AKDropdownMenu Component using passed in props and options. If
142
+     * the dropdown needs to be disabled, then only the AKDropdownMenu trigger
143
+     * element is returned to simulate a disabled state.
142
      *
144
      *
143
      * @param {Object} options - Additional configuration for display.
145
      * @param {Object} options - Additional configuration for display.
144
      * @param {Object} options.defaultSelected - The option that should be set
146
      * @param {Object} options.defaultSelected - The option that should be set
145
      * as currently chosen.
147
      * as currently chosen.
146
-     * @param {boolean} options.isDisabled - If true, AKDropdownMenu will not
147
-     * open on click.
148
+     * @param {boolean} options.isDisabled - If true, only the AKDropdownMenu
149
+     * trigger component will be returned to simulate a disabled dropdown.
148
      * @param {Array} options.items - All the selectable options to display.
150
      * @param {Array} options.items - All the selectable options to display.
149
      * @param {string} options.placeholder - The translation key to display when
151
      * @param {string} options.placeholder - The translation key to display when
150
      * no selection has been made.
152
      * no selection has been made.
155
         const triggerText
157
         const triggerText
156
             = (options.defaultSelected && options.defaultSelected.content)
158
             = (options.defaultSelected && options.defaultSelected.content)
157
                 || options.placeholder;
159
                 || options.placeholder;
160
+        const trigger = this._createDropdownTrigger(triggerText);
161
+
162
+        if (options.isDisabled) {
163
+            return (
164
+                <div className = 'device-selector-trigger-disabled'>
165
+                    { trigger }
166
+                </div>
167
+            );
168
+        }
158
 
169
 
159
         return (
170
         return (
160
             <AKDropdownMenu
171
             <AKDropdownMenu
161
-                { ...(options.isDisabled && { isOpen: !options.isDisabled }) }
162
                 items = { [ { items: options.items || [] } ] }
172
                 items = { [ { items: options.items || [] } ] }
163
-                noMatchesFound
164
-                    = { this.props.t('deviceSelection.noOtherDevices') }
165
                 onItemActivated = { this._onSelect }
173
                 onItemActivated = { this._onSelect }
166
                 shouldFitContainer = { true }>
174
                 shouldFitContainer = { true }>
167
-                { this._createDropdownTrigger(triggerText) }
175
+                { trigger }
168
             </AKDropdownMenu>
176
             </AKDropdownMenu>
169
         );
177
         );
170
     }
178
     }
208
     _renderNoPermission() {
216
     _renderNoPermission() {
209
         return this._createDropdown({
217
         return this._createDropdown({
210
             isDisabled: true,
218
             isDisabled: true,
211
-            placeholder: this.props.t('settings.noPermission')
219
+            placeholder: this.props.t('deviceSelection.noPermission')
212
         });
220
         });
213
     }
221
     }
214
 }
222
 }

Loading…
Cancel
Save