Skip to content

[Dropzone] Upload same file empty the drop zone, chrome only #2552

Open
@nforgeot-norsys

Description

@nforgeot-norsys

When you upload the same file, Chrome do not trigger change event. Firefox do. I think Chrome have the correct behavior this time.

This behavior introduced an issue in the UX dropzone. In chrome, when you upload the same file, the dropzone is emptied.

bug_dropzone_same_file.webm

Solution : Listen the drop event and show the drop zone if a input value is set.

What do you think of this solution ? Tested ok in Chrome and Firefox.

in https://github.com/symfony/ux/blob/v2.22.1/src/Dropzone/assets/dist/controller.js

    initialize() {
        // ...
        this.onDrop = this.onDrop.bind(this);
    }

    connect() {
        // ...
        this.element.addEventListener('drop', this.onDrop);
    }

    disconnect() {        // ...
        this.element.removeEventListener('drop', this.onDrop);
    }

    onDrop() {
        if (this.inputTarget.value === '') {
            return;
        }

        this.inputTarget.style.display = 'none';
        this.placeholderTarget.style.display = 'none';
        this.previewTarget.style.display = 'flex';
    }

If it's ok for you, I can try to do the PR ;)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions