You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #3843 [Dropzone] Fix the drop zone appearing empty when the same file is dropped again (Kocal)
This PR was merged into the 3.x branch.
Discussion
----------
[Dropzone] Fix the drop zone appearing empty when the same file is dropped again
| Q | A
| -------------- | ---
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Documentation? | no
| Issues | Fix#2552
| License | MIT
Dragging a file over the drop zone makes `onDragEnter` reveal the input and hide the preview. Dropping a *different* file then fires `change`, `onInputChange` runs and restores the preview. Dropping the **same** file does not: Chrome fires no `change` event when the selection is unchanged, and `dragleave` does not fire either since the pointer never leaves the element. Nothing restores the preview, so the zone looks empty while a file is still selected.
The controller now also listens for `drop` and restores the preview when the input still holds a file. The check is deferred so it runs after `input.files` has settled and after any `change` event, which makes it a no-op when the browser did fire one.
Reproduced in Chrome before and after: with the published controller, the sequence pick, `dragenter`, `drop` leaves `preview: none` while `input.files.length` is 1; with this change it goes back to `preview: flex`. The added unit test covers the same sequence and fails without the fix.
The e2e application only had a `multiple` Dropzone page, so this adds a single-file one at `/ux-dropzone/single` and registers it as an example, which is what made the browser check possible.
Commits
-------
69669d3 [Dropzone] Fix the drop zone appearing empty when the same file is dropped again
Copy file name to clipboardExpand all lines: apps/e2e/src/Repository/ExampleRepository.php
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ public function __construct()
37
37
newExample(UxPackage::ChartJs, 'Pie chart with options', 'A pie chart with custom options to control the appearance and behavior.', 'app_ux_chartjs_pie_with_options'),
38
38
newExample(UxPackage::Cropperjs, 'Image cropper', 'Crop an image with Cropper.js using default options.', 'app_ux_cropperjs_crop'),
39
39
newExample(UxPackage::Cropperjs, 'Image cropper with aspect ratio', 'Crop an image with a fixed 16:9 aspect ratio constraint.', 'app_ux_cropperjs_crop_with_aspect_ratio'),
40
+
newExample(UxPackage::Dropzone, 'Single file upload', 'Upload one file, with a preview and a clear button.', 'app_ux_dropzone_single'),
40
41
newExample(UxPackage::Dropzone, 'Multiple file upload', 'Upload several files at once: accumulate across picks, preview each, and remove individually.', 'app_ux_dropzone_multiple'),
41
42
newExample(UxPackage::LiveComponent, 'Examples filtering', 'On this page, you can filter all examples by query terms, and observe how the UI and URLs update during and after processing.', 'app_home'),
42
43
newExample(UxPackage::LiveComponent, 'Counter', 'A basic counter that you can increment or decrement.', 'app_ux_live_component_counter'),
0 commit comments