[Dropzone] Add multiple file preview - #2747
Conversation
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
|||||||||||||||
| readonly previewFilenameTarget: HTMLDivElement; | ||
| readonly previewImageTarget: HTMLDivElement; | ||
| readonly placeholderTarget: HTMLElement; | ||
| readonly previewTargets: HTMLElement[]; |
There was a problem hiding this comment.
Possible breaking change? Some controller targets have been removed and I've changed types on placeholderTarget and previewTarget so they're more generic. For example, the new placeholder is a <label> not a <div>, so I changed placeholderTarget type from HTMLDivElement to the more generic HTMLElement.
Since the documentation suggests using event listeners to extend behaviour I assumed the controller class wouldn't be extended directly, so perhaps these aren't breaking changes.
|
I can add tests/docs when we're nearly ready to merge. Didn't want to add tests for features that may be dropped during review. |
|
User is a ghost, closing |
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
legacystyle:(File list shown in native browser tooltip by setting filename element's
titleattribute)New
inlinestyle:New
blockstyle:New
blockstyle withpreview.can_toggle_placeholder = false:Added
preview.styleoption. The (default)legacyoption reproduces existing behaviour. Theblockandinlineoptions enable new features.Added
preview.can_toggle_placeholderoption to control whether placeholder remains visible when preview is rendered. Can betrue,falseorauto. Theautooption will hide placeholder for single-file uploads; adding additional files will show placeholder again.Added
preview.can_open_file_pickeroption 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