-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(b-form-file): improved drag and drop handling (closes #3673) #5727
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
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/bootstrap-vue/bootstrap-vue/2yfixz43d |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5225ddf:
|
Codecov Report
@@ Coverage Diff @@
## dev #5727 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 284 284
Lines 9584 9636 +52
Branches 2531 2549 +18
=========================================
+ Hits 9584 9636 +52
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3dfcc86:
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 371d3f7:
|
…hub.com/bootstrap-vue/bootstrap-vue into feat-b-form-file-advanced-drag-and-drop
Describe the PR
This PR is based on the changes of #3674.
Drag and drop files bypasses the file input altogether, which makes native browser validation constraints (i.e.
required
) not work, as the input does not reflect the dropped files.Chrome, Firefox, Safari, Edge support dropping files directly on a file input, but IE11 and some older browser versions do not, so we can't take advantage of the native file input drop features (which would simplify the code drastically, and retain proper validity state).
All modern browsers support setting
InputElement.files
to aFileList
array (which will satisfyrequired
constraint), but again IE 11 doesn't support this (could be placed in a try/catch to trap/mask errors).What's new and changes:
FileList
, filtered by accept criteria), so thatrequired
prop works with drag/drop (except on IE, the attempt to set the files is wrapped in a try/catch to suppress the error)accept
criteria. Converts theaccept
prop to an array of regular expressions for testing the file type/extension of dropped filesdirectory
setting (Except IE, which doesn't support directory mode)z-index
on the opaque file input so that it doesn't interfere with drag/drop on IE (and other browsers). Clicking the custom input label will still open the native file browser (as the label is associated with the input via thefor
attribute).scoped
slot are now always flattened (even in directory mode), but includes a new scoped property which provides the files in traversed mode<b-form-file>
docsTODO:
accept
file matching testsdropEffect
to'none'
when file(s) can't be dropped (works on all but IE 11, as files are not known until the drop event happens)valid
scope prop (not applicable to IE 11, as files aren't known until dropped)Promise
support for drag and drop modeplaceholder
prompt, anddrop-placeholder
prompt, as an alternative to the props.Closes #3673.
PR checklist
What kind of change does this PR introduce? (check at least one)
fix(...)
, requires a patch version updatefeat(...)
, requires a minor version updatefeat(...)
, requires a minor version updatefix(...)
, requires a patch or minor version updatechore(docs)
, requires a patch version updateDoes this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
dev
branch, not themaster
branch[...] (fixes #xxx[,#xxx])
, where "xxx" is the issue number)fix(alert): not alerting during SSR render
,docs(badge): update pill examples
,chore(docs): fix typo in README
, etc). This is very important, as theCHANGELOG
is generated from these messages, and determines the next version type (patch or minor).If new features/enhancement/fixes are added or changed:
If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes: