[Dropzone] Add multiple file preview #2747
Open
+909
−163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updated Dropzone component to support multiple file preview.
No breaking changes. Backwards compatible by default. User can opt-in to new features.
Example:
Demo repo
Basic support for
legacy
style:(File list shown in tooltip by setting file name element's
title
attribute)New
inline
style:New
block
style:New
block
style withpreview.can_toggle_placeholder = false
:Added
preview.style
option. The (default)legacy
option reproduces existing behaviour. Theblock
andinline
options enable new features.Added
preview.can_toggle_placeholder
option to control whether placeholder remains visible when preview is rendered. Can betrue
,false
orauto
. Theauto
option will hide placeholder for single-file uploads; adding additional files will show placeholder again.Added
preview.can_open_file_picker
option to control whether clicking preview container opens input file picker.New component handles drop event directly, making cross-browser behaviour consistent (#2552); i.e. it does not rely on file input for drop handling.
Each selected file has its own preview. Thumbnails are shown for image files and a placeholder for other files. Files can be added/removed individually.
File preview template, button image and placeholder image markup can be overridden by adding content to corresponding form theme blocks, allowing markup customization without having to override entire form theme.
File input hidden to improve component style flexibility[1]. Input still visible to screen readers.
File input wrapped within label so label can obtain focus, allowing keyboard/screen reader navigation.
Component is outlined on drag hover, providing feedback that mouse is detected within dropzone.
Legacy code clearly marked so it can be removed from component during next major release (if desired).
Related issues:
#2567
#2552
#1025
#7
Related PR's:
#2704
#2642
#512