Skip to content

Commit e2bc891

Browse files
authored
feat(form-file): Use label as wrapper element + name-spaced custom CSS (bootstrap-vue#1353)
The original Microsoft Edge bug that affected for inputs wrapped in a label element has been fixed as of May 2017. https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8282613/ So we can revert back to using the `<label>` element as the wrapper for the custom file input. This PR also name-spaces the Bootstrap-Vue custom `custom-file` CSS to negate the need for scoped CSS.
1 parent 6a1ef4f commit e2bc891

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

src/components/form-file/form-file.vue

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
<style scoped>
2-
/* Custom-file focus styling: These can be removed once BSV4.beta.3 is released */
1+
<style>
2+
/* Custom-file focus styling: These can possibly be removed once BSV4.beta.3 is released */
3+
/* Although the focus handling/style will still be needed for Firefox keyboard-only users */
4+
35
/* Regular focus styling */
4-
.custom-file-input.focus ~ .custom-file-control,
5-
.custom-file-input:focus ~ .custom-file-control {
6+
.b-form-file.custom-file .custom-file-input.focus ~ .custom-file-control,
7+
.b-form-file.custom-file .custom-file-input:focus ~ .custom-file-control {
68
color: #495057;
79
background-color: #fff;
810
border-color: #80bdff;
911
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
1012
outline: none;
1113
}
1214
/* Invalid focus styling */
13-
.custom-file-input.is-invalid.focus ~ .custom-file-control,
14-
.custom-file-input.is-invalid:focus ~ .custom-file-control,
15-
.was-validated .custom-file-input:invalid.focus ~ .custom-file-control,
16-
.was-validated .custom-file-input:invalid:focus ~ .custom-file-control {
15+
.b-form-file.custom-file .custom-file-input.is-invalid.focus ~ .custom-file-control,
16+
.b-form-file.custom-file .custom-file-input.is-invalid:focus ~ .custom-file-control,
17+
.was-validated .b-form-file.custom-file .custom-file-input:invalid.focus ~ .custom-file-control,
18+
.was-validated .b-form-file.custom-file .custom-file-input:invalid:focus ~ .custom-file-control {
1719
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
1820
border-color: #dc3545;
1921
}
2022
/* valid focus styling */
21-
.custom-file-input.is-valid.focus ~ .custom-file-control,
22-
.custom-file-input.is-valid:focus ~ .custom-file-control,
23-
.was-validated .custom-file-input:valid.focus ~ .custom-file-control,
24-
.was-validated .custom-file-input:valid:focus ~ .custom-file-control {
23+
.b-form-file.custom-file .custom-file-input.is-valid.focus ~ .custom-file-control,
24+
.b-form-file.custom-file .custom-file-input.is-valid:focus ~ .custom-file-control,
25+
.was-validated .b-form-file.custom-file .custom-file-input:valid.focus ~ .custom-file-control,
26+
.was-validated .b-form-file.custom-file .custom-file-input:valid:focus ~ .custom-file-control {
2527
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
2628
border-color: #28a745;
2729
}
2830
2931
/* Drag/Drop and filenames/prompts handling */
30-
.custom-file-control {
32+
.b-form-file.custom-file .custom-file-control {
3133
overflow: hidden;
3234
}
33-
.custom-file-control {
35+
.b-form-file.custom-file .custom-file-control {
3436
overflow: hidden;
3537
}
36-
.custom-file-control.dragging {
38+
.b-form-file.custom-file .custom-file-control.dragging {
3739
overflow: hidden;
3840
filter: blur(3px);
3941
}
40-
.custom-file-control[data-selected]::after {
42+
.b-form-file.custom-file .custom-file-control[data-selected]::after {
4143
content: attr(data-selected);
4244
}
43-
.custom-file-control[data-choose]::before {
45+
.b-form-file.custom-file .custom-file-control[data-choose]::before {
4446
content: attr(data-choose);
4547
}
46-
.custom-file .drop-here {
48+
.b-form-file.custom-file .drop-here {
4749
position: absolute;
4850
left: 0;
4951
right: 0;
@@ -56,7 +58,7 @@
5658
justify-content: center;
5759
align-items: center;
5860
}
59-
.custom-file .drop-here::before {
61+
.b-form-file.custom-file .drop-here::before {
6062
color: white;
6163
content: attr(data-drop);
6264
}
@@ -134,9 +136,9 @@
134136
135137
// Return rendered custom file input
136138
return h(
137-
'div',
139+
'label',
138140
{
139-
class: [ 'custom-file', 'w-100', t.stateClass ],
141+
class: [ 'custom-file', 'b-form-file', 'w-100', t.stateClass ],
140142
attrs: { id: t.safeId('_BV_file_outer_') },
141143
on: { dragover: t.dragover }
142144
},

0 commit comments

Comments
 (0)