-
-
Notifications
You must be signed in to change notification settings - Fork 357
[Dropzone] Add multiple file preview #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
c137c69
to
79759ae
Compare
79759ae
to
78a7709
Compare
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 native browser tooltip by setting filename 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