Open
Description
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 ;)
Activity
smnandre commentedon Feb 7, 2025
Hey @nforgeot-norsys ! Not 100% sur to get how the problem occurs (i probably missed something)
I had the impression that either onchage was triggerd, and current file was replaced, onchange was not triggered, so current file stayed there...
Do you have any other script involved here ?
nforgeot-norsys commentedon Feb 10, 2025
Hey @smnandre
Yes that it. It's Chrome behaviour. But Firefox trigger every time.
No I don't have other script involved in this behavior. I have made a little test in a sandbox to demonstrate that https://jsfiddle.net/a6jng31u/ .