Skip to content

Commit 27dccfa

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
FileUploader: Set empty label text on mobile devices (DevExpress#30233)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent 532cce4 commit 27dccfa

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

packages/devextreme/js/__internal/ui/m_file_uploader.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ class FileUploader extends Editor<FileUploaderProperties> {
218218
}
219219

220220
_defaultOptionsRules() {
221-
// @ts-expect-error
222221
return super._defaultOptionsRules().concat([
223222
{
224223
device: () => devices.real().deviceType === 'desktop' && !devices.isSimulator(),
@@ -239,7 +238,10 @@ class FileUploader extends Editor<FileUploaderProperties> {
239238
{
240239
device: () => devices.real().deviceType !== 'desktop',
241240
options: {
241+
// @ts-expect-error
242242
useDragOver: false,
243+
nativeDropSupported: false,
244+
labelText: '',
243245
},
244246
},
245247
{
@@ -248,12 +250,6 @@ class FileUploader extends Editor<FileUploaderProperties> {
248250
uploadMode: 'useForm',
249251
},
250252
},
251-
{
252-
device: () => devices.real().deviceType !== 'desktop',
253-
options: {
254-
nativeDropSupported: false,
255-
},
256-
},
257253
{
258254
// @ts-expect-error
259255
device: () => isMaterial(),

packages/devextreme/js/ui/file_uploader.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export interface dxFileUploaderOptions extends EditorOptions<dxFileUploader> {
272272
/**
273273
* @docid
274274
* @default "or Drop file here"
275-
* @default "" &for(InternetExplorer|desktop)
275+
* @default "" &for(mobile_devices)
276276
* @public
277277
*/
278278
labelText?: string;

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/fileUploader.tests.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Deferred } from 'core/utils/deferred';
66
import keyboardMock from '../../helpers/keyboardMock.js';
77
import { createBlobFile } from '../../helpers/fileHelper.js';
88
import { getFileChunkCount } from '../../helpers/fileManagerHelpers.js';
9-
import { shouldSkipOnMobile } from '../../helpers/device.js';
9+
import { shouldSkipOnDesktop, shouldSkipOnMobile } from '../../helpers/device.js';
1010
import '../../helpers/xmlHttpRequestMock.js';
1111
import 'generic_light.css!';
1212

@@ -269,7 +269,7 @@ QUnit.module('custom uploading', moduleConfig, () => {
269269
const chunkSize = 20000;
270270
const fileSize = 50100;
271271
const uploadChunkSpy = sinon.spy((file, chunksInfo) => {
272-
lastCustomData = $.extend(true, { }, chunksInfo.customData);
272+
lastCustomData = $.extend(true, {}, chunksInfo.customData);
273273
chunksInfo.customData.testCounter = chunksInfo.customData.testCounter || 0;
274274
chunksInfo.customData.testCounter++;
275275
return executeAfterDelay();
@@ -287,7 +287,7 @@ QUnit.module('custom uploading', moduleConfig, () => {
287287

288288
this.clock.tick(500);
289289
assert.strictEqual(uploadChunkSpy.callCount, 1, 'custom function called for 1st chunk');
290-
assert.deepEqual(lastCustomData, { }, 'custom data is empty');
290+
assert.deepEqual(lastCustomData, {}, 'custom data is empty');
291291

292292
this.clock.tick(1000);
293293
assert.strictEqual(uploadChunkSpy.callCount, 2, 'custom function called for 2nd chunk');
@@ -476,7 +476,7 @@ QUnit.module('custom uploading', moduleConfig, () => {
476476
return executeAfterDelay();
477477
});
478478
const abortUploadSpy = sinon.spy((file, chunksInfo) => {
479-
lastCustomData = $.extend(true, { }, chunksInfo.customData);
479+
lastCustomData = $.extend(true, {}, chunksInfo.customData);
480480
return executeAfterDelay();
481481
});
482482

@@ -944,7 +944,7 @@ QUnit.module('uploading by chunks', moduleConfig, function() {
944944
let fileUploadedCount = 0;
945945
let totalBytes = 0;
946946
let totalLoadedBytes = 0;
947-
const fileStates = { };
947+
const fileStates = {};
948948

949949
const files = [createBlobFile('fake1.png', 100023), createBlobFile('fake2.png', 5000)];
950950
files.forEach(function(item) {
@@ -3931,6 +3931,10 @@ QUnit.module('Drag and drop', moduleConfig, () => {
39313931
});
39323932

39333933
QUnit.test('Default label text must be shown if upload mode is useForm and native drop is supported (T936087)', function(assert) {
3934+
if(shouldSkipOnMobile(assert, 'default label text is hidden for mobile devices')) {
3935+
return;
3936+
}
3937+
39343938
const defaultLabelText = 'or Drop a file here';
39353939
const $fileUploader = $('#fileuploader').dxFileUploader({
39363940
uploadMode: 'useForm',
@@ -4061,11 +4065,14 @@ QUnit.module('disabled option', () => {
40614065
});
40624066

40634067
QUnit.test('label text must be visible when disabled option changed dynamically', function(assert) {
4068+
const defaultLabelText = 'or Drop a file here';
4069+
40644070
const $fileUploader = $('#fileuploader').dxFileUploader({
40654071
disabled: true,
40664072
useDragOver: true,
40674073
nativeDropSupported: true,
4068-
uploadMode: 'useForm'
4074+
uploadMode: 'useForm',
4075+
labelText: defaultLabelText,
40694076
});
40704077
const $inputContainer = $fileUploader.find('.' + FILEUPLOADER_INPUT_CONTAINER_CLASS);
40714078
const $inputLabel = $inputContainer.find('.' + FILEUPLOADER_INPUT_LABEL_CLASS);
@@ -4075,7 +4082,7 @@ QUnit.module('disabled option', () => {
40754082

40764083
$fileUploader.dxFileUploader('option', 'disabled', false);
40774084
assert.ok($inputContainer.is(':visible'), 'input container is visible');
4078-
assert.strictEqual($inputLabel.text(), 'or Drop a file here', 'label has default text');
4085+
assert.strictEqual($inputLabel.text(), defaultLabelText, 'label has default text');
40794086
});
40804087
});
40814088

@@ -4086,7 +4093,8 @@ QUnit.module('readOnly option', moduleConfig, () => {
40864093
const $fileUploader = $('#fileuploader').dxFileUploader({
40874094
readOnly: false,
40884095
useDragOver: true,
4089-
uploadMode: 'useButtons'
4096+
uploadMode: 'useButtons',
4097+
labelText: defaultLabelText
40904098
});
40914099
const $inputContainer = $fileUploader.find('.' + FILEUPLOADER_INPUT_CONTAINER_CLASS);
40924100
const $inputLabel = $inputContainer.find('.' + FILEUPLOADER_INPUT_LABEL_CLASS);
@@ -4335,3 +4343,16 @@ QUnit.module('integration of dx button components via dialogTrigger', moduleConf
43354343
});
43364344
});
43374345
});
4346+
4347+
QUnit.module('labelText', moduleConfig, () => {
4348+
QUnit.test('Dropzone default label text should be hidden on mobile devices', function(assert) {
4349+
if(shouldSkipOnDesktop(assert, 'should only apply on mobile devices')) {
4350+
return;
4351+
}
4352+
4353+
const $fileUploader = $('#fileuploader').dxFileUploader();
4354+
const $inputLabel = $fileUploader.find(`.${FILEUPLOADER_INPUT_LABEL_CLASS}`);
4355+
4356+
assert.strictEqual($inputLabel.text(), '', 'default label is hidden on mobile');
4357+
});
4358+
});

0 commit comments

Comments
 (0)