-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Custom Forms: Allow Chrome/Firefox feature that lets the user drag and drop into file inputs #20033
Conversation
|
True, but in that case wouldn't this effectively do nothing for IE users? This is, after all, not a standard feature of I just tested drag and drop on jsfiddle for both IE11 and Edge, and neither of them support the functionality that Chrome does, so I doubt IE 9 or 10 have it. Just tried it on Firefox 46 with success, for what it's worth. The changed .custom-file does look strange on Firefox: Unlike chrome, it horizontally expands the input to accommodate added files, while the text box still shows an unchanged "Choose file...". Of course it behaved like that before the patch too, but the explorer dialogue hid the sudden resizing. |
Huh, I wasn't aware that drag-file-into-file-input wasn't supported in IE/Edge, but you're right. |
@@ -210,6 +210,8 @@ | |||
.custom-file-input { | |||
min-width: $custom-file-width; | |||
max-width: 100%; | |||
padding-top: $custom-file-padding-y; | |||
padding-bottom: $custom-file-padding-y; |
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.
The shorthand is still used below, so why add these?
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.
This padding is to make the hidden element match the height of the custom control. Without this extra height, files can only be dragged onto the top half of the control.
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.
Wouldn't height
make more sense to set?
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.
My point was more that these 2 lines seem redundant due to these: https://github.com/twbs/bootstrap/pull/20033/files/3e5c6dcc07dc25dbb0e11411bef68a17ad8e9c2a#diff-e5540857a54676b43146ad92add2dbdeR231
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.
As I said before, it's to make the invisible input the same height as the visible .custom-file-control. Without it, dragging something onto the lower third of the button doesn't work. changing height does the same thing while looking cleaner though, so that's how it works now.
This is less a feature and more of a slight improvement and maybe a bug fix (since this is browser behavior for many folks). Should be able to merge, but I did have a question on the use of padding vs height on the hidden input. |
Good call on height, I admit my css experience is limited. One thing I noticed is that this change breaks edit: Here's what I mean: https://gfycat.com/ShoddySleepyFlea - Note this shows what it would look like if the cursor style was applied to the input. As of the current commit the cursor is never a pointer. |
Chrome (among other browsers) allows you to drag and drop files from the desktop into
<input type="file">
form elements. Bootstrap 4's custom file input covers up the base input, so drag and drop doesn't work.This patch disables
pointer-events
on the custom element so dropped files pass through to the invisible, full-height input behind it. Normal clicks work just as they did.