Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions e2e/testcafe-devextreme/tests/editors/fileUploader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createWidget } from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';

const TEST_FILE = './images/test-image-1.png';
const LONG_LABEL_TEXT = 'Drag a file from your computer and drop it here, or click the button to choose one';

fixture`FileUploader - file list visibility`
.page(url(__dirname, '../../container.html'));
Expand All @@ -25,3 +26,18 @@ fixture`FileUploader - file list visibility`
await t.expect(compareResults.isValid()).ok(compareResults.errorMessages());
}).before(async () => createWidget('dxFileUploader', { showFileList }));
});

fixture`FileUploader - label`
.page(url(__dirname, '../../container.html'));

[false, true].forEach((rtlEnabled) => {
test(`FileUploader label should not be cut while there is free space, rtlEnabled: ${rtlEnabled} (T1337565)`, async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);

await testScreenshot(t, takeScreenshot, `fileuploader-long-label-rtl-${rtlEnabled}.png`, {
element: '#container',
});

await t.expect(compareResults.isValid()).ok(compareResults.errorMessages());
}).before(async () => createWidget('dxFileUploader', { labelText: LONG_LABEL_TEXT, rtlEnabled }));
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fixture`HtmlEditor - common`
.page(url(__dirname, '../../../../container-extended.html'));

const ADD_IMAGE_POPUP_CONTENT_SELECTOR = '.dx-htmleditor-add-image-popup .dx-overlay-content';
const LONG_FILE_UPLOADER_LABEL_TEXT = 'Drop an image here or click the button to browse';

test('TabPanel in HtmlEditor must have correct borders', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
Expand All @@ -36,6 +37,33 @@ test('TabPanel in HtmlEditor must have correct borders', async (t) => {
});
});

test('File uploader label container should keep the full dialog width', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');

await t.click(htmlEditor.toolbar.getItemByName('image'));

await testScreenshot(t, takeScreenshot, 'htmleditor-add-image-long-file-uploader-label.png', {
element: ADD_IMAGE_POPUP_CONTENT_SELECTOR,
});

await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file'],
fileUploaderOptions: {
labelText: LONG_FILE_UPLOADER_LABEL_TEXT,
},
},
toolbar: { items: ['image'] },
});
});

test('Add button should be enabled after switch to url form', async (t) => {
const htmlEditor = new HtmlEditor('#container');

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 3 additions & 25 deletions packages/devextreme-scss/scss/widgets/base/_fileUploader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,10 @@
}

.dx-fileuploader-input-wrapper {
@include dx-clearfix-mixin();

&::before,
&::after {
width: 100%;
}

&::before {
padding-top: 1em;
margin-top: -1em;
}

&::after {
padding-bottom: 1em;
margin-bottom: -1em;
}
display: flex;

.dx-button {
float: left;
flex-shrink: 0;
}

.dx-button + .dx-button {
Expand Down Expand Up @@ -122,15 +107,8 @@
}
}

.dx-fileuploader-button-container,
.dx-fileuploader-input-container {
display: table-cell;
vertical-align: middle;
}

.dx-fileuploader-input-container {
height: 100%;
width: 100%;
flex-grow: 1;
position: relative;
overflow: hidden;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@
border-radius: $fluent-html-editor-fileuploader-input-wrapper-border-radius;
background-color: $htmleditor-fileuploader-input-wrapper-bg-color;

&::after,
&::before {
content: none;
.dx-fileuploader-input-container {
width: 100%;
}

.dx-fileuploader-input-label {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class FileManagerFileUploader extends Widget<FileManagerFileUploaderOptions> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return (
uploaderInstance.isMouseOverElement(e, this.option('splitterElement'))
|| uploaderInstance._shouldRaiseDragLeaveBase(e, true)
|| uploaderInstance._shouldRaiseDragLeaveBase(e)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ class FileUploader extends Editor<FileUploaderProperties> {
dropZoneElement?: Element,
): boolean | string | undefined {
return this._activeDropZone === null
&& this.isMouseOverElement(e, dropZoneElement as HTMLElement, false)
&& this.isMouseOverElement(e, dropZoneElement as HTMLElement)
&& e.originalEvent.dataTransfer.types.find((item) => item === 'Files');
}

Expand All @@ -1230,12 +1230,12 @@ class FileUploader extends Editor<FileUploaderProperties> {
}
e.originalEvent.dataTransfer.dropEffect = 'copy';

if (!isCustomTarget) { // only default dropzone has pseudoelements
if (!isCustomTarget) {
const dropZoneElement = this._getDropZoneElement(false, e);
if (this._shouldRaiseDragOver(e, dropZoneElement)) {
this._dragEnterHandler(false, e);
}
if (this._shouldRaiseDragLeave(e, false)) {
if (this._shouldRaiseDragLeave(e)) {
this._dragLeaveHandler(false, e);
}
}
Expand All @@ -1246,18 +1246,17 @@ class FileUploader extends Editor<FileUploaderProperties> {
e.preventDefault();
}

if (this._shouldRaiseDragLeave(e, isCustomTarget)) {
if (this._shouldRaiseDragLeave(e)) {
this._tryToggleDropZoneActive(false, isCustomTarget, e);
this._activeDropZone = null;
}
}

_shouldRaiseDragLeave(e: MouseLikeEvent, isCustomTarget: boolean): boolean {
_shouldRaiseDragLeave(e: MouseLikeEvent): boolean {
return this._activeDropZone !== null
&& !this.isMouseOverElement(
e,
this._activeDropZone as HTMLElement,
!isCustomTarget,
-DRAG_EVENT_DELTA,
);
}
Expand Down Expand Up @@ -1517,17 +1516,13 @@ class FileUploader extends Editor<FileUploaderProperties> {
isMouseOverElement(
mouseEvent: MouseLikeEvent,
element?: HTMLElement,
correctPseudoElements?: boolean,
dragEventDelta: number = DRAG_EVENT_DELTA,
): boolean {
if (!element) return false;

const beforeHeight = correctPseudoElements ? parseFloat(window.getComputedStyle(element, ':before').height) : 0;
const afterHeight = correctPseudoElements ? parseFloat(window.getComputedStyle(element, ':after').height) : 0;
const x = getOffset(element).left;
const y = getOffset(element).top + beforeHeight;
const { left: x, top: y } = getOffset(element);
const w = element.offsetWidth;
const h = element.offsetHeight - beforeHeight - afterHeight;
const h = element.offsetHeight;
const eventX = this._getEventX(mouseEvent);
const eventY = this._getEventY(mouseEvent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4078,6 +4078,28 @@ QUnit.module('Drag and drop', moduleConfig, () => {
assert.strictEqual(onDropZoneLeaveSpy.args[0][0].dropZoneElement, $inputWrapper[0], 'dropZone argument is correct');
});

QUnit.test('default drop zone should stay active while a file is dragged over it', function(assert) {
const onDropZoneLeaveSpy = sinon.spy();
const $fileUploader = $('#fileuploader').dxFileUploader({
uploadMode: 'useButtons',
onDropZoneLeave: onDropZoneLeaveSpy
});
const $inputWrapper = $fileUploader.find('.' + FILEUPLOADER_INPUT_WRAPPER_CLASS);
const { left, top } = $inputWrapper.offset();

triggerDragEvent($inputWrapper, 'dragenter');
assert.ok($fileUploader.hasClass('dx-fileuploader-dragover'), 'drop zone is active after dragenter');

$inputWrapper.trigger($.Event('dragover', {
clientX: left + $inputWrapper.outerWidth() / 2,
clientY: top + $inputWrapper.outerHeight() / 2,
originalEvent: $.Event('dragover', { dataTransfer: { types: ['Files'] } })
}));

assert.ok($fileUploader.hasClass('dx-fileuploader-dragover'), 'drop zone is still active after dragover');
assert.ok(onDropZoneLeaveSpy.notCalled, 'dropZoneLeave not called');
});

QUnit.test('dropZoneEnter and dropZoneLeave events should not fire if dragged item is not file', function(assert) {
const onDropZoneEnterSpy = sinon.spy();
const onDropZoneLeaveSpy = sinon.spy();
Expand Down
Loading