Преглед изворни кода

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 година
родитељ
комит
4e95dbf0e5

+ 6
- 0
css/modals/device-selection/_device-selection.scss Прегледај датотеку

@@ -36,6 +36,12 @@
36 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 46
         .device-selector-trigger-text {
41 47
             overflow: hidden;

+ 1
- 2
lang/main.json Прегледај датотеку

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

+ 16
- 8
react/features/device-selection/components/DeviceSelector.js Прегледај датотеку

@@ -138,13 +138,15 @@ class DeviceSelector extends Component {
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 145
      * @param {Object} options - Additional configuration for display.
144 146
      * @param {Object} options.defaultSelected - The option that should be set
145 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 150
      * @param {Array} options.items - All the selectable options to display.
149 151
      * @param {string} options.placeholder - The translation key to display when
150 152
      * no selection has been made.
@@ -155,16 +157,22 @@ class DeviceSelector extends Component {
155 157
         const triggerText
156 158
             = (options.defaultSelected && options.defaultSelected.content)
157 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 170
         return (
160 171
             <AKDropdownMenu
161
-                { ...(options.isDisabled && { isOpen: !options.isDisabled }) }
162 172
                 items = { [ { items: options.items || [] } ] }
163
-                noMatchesFound
164
-                    = { this.props.t('deviceSelection.noOtherDevices') }
165 173
                 onItemActivated = { this._onSelect }
166 174
                 shouldFitContainer = { true }>
167
-                { this._createDropdownTrigger(triggerText) }
175
+                { trigger }
168 176
             </AKDropdownMenu>
169 177
         );
170 178
     }
@@ -208,7 +216,7 @@ class DeviceSelector extends Component {
208 216
     _renderNoPermission() {
209 217
         return this._createDropdown({
210 218
             isDisabled: true,
211
-            placeholder: this.props.t('settings.noPermission')
219
+            placeholder: this.props.t('deviceSelection.noPermission')
212 220
         });
213 221
     }
214 222
 }

Loading…
Откажи
Сачувај