-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(b-form-file): ensure drag/drop handles required
prop correctly (except IE11), add drag/drop accept type handling, fix drop in IE11 (closes #3673)
#3674
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## dev #3674 +/- ##
==========================================
- Coverage 99.86% 99.66% -0.20%
==========================================
Files 238 236 -2
Lines 4470 4519 +49
Branches 1260 1273 +13
==========================================
+ Hits 4464 4504 +40
- Misses 5 11 +6
- Partials 1 4 +3
Continue to review full report at Codecov.
|
jacobmllr95
reviewed
Jul 11, 2019
required
prop correctly, add drag/drop accept type handling, fix drop in IE11 (closes #3673)required
prop correctly (except IE11), add drag/drop accept type handling, fix drop in IE11 (closes #3673)
32 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Describe the PR
Note: New PR required
Closes #3673 (except for IE 11, sorry)
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).overflow-hidden
to custom label to prevent filenames from "breaking out" of custom file controlscoped
slot are now always flattened (even in directory mode), but includes a new scoped property which provides the files in traversed modeTODO:
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.Notes: Bootstrap v5 has a new structure for the custom label, which allows for better flexibility in handling overflowing names. We may want to consider using this newer format with Bootstrap v4.x (with a bit of custom SCSS, with variable sniffing) to take advantage of the new structure (and prepare for v5 when it is released)
PR checklist
What kind of change does this PR introduce? (check at least one)
Does 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, fix typos
,chore: fix typo in README
, etc). This is very important, as theCHANGELOG
is generated from these messages.If new features/enhancement/fixes are added or changed:
package.json
for slot and event changes)If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes: