Skip to content

Commit 2ed4b3d

Browse files
authored
Merge pull request #4201 from Laravel-Backpack/fix-select2-placeholder-when-inside-tabs
add css that forces width on select2 placeholder
2 parents d19b143 + 65bfaeb commit 2ed4b3d

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

src/resources/views/crud/inc/show_tabbed_fields.blade.php

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@
77
}
88
@endphp
99

10-
@push('crud_fields_styles')
11-
<style>
12-
.nav-tabs-custom {
13-
box-shadow: none;
14-
}
15-
.nav-tabs-custom > .nav-tabs.nav-stacked > li {
16-
margin-right: 0;
17-
}
18-
19-
.tab-pane .form-group h1:first-child,
20-
.tab-pane .form-group h2:first-child,
21-
.tab-pane .form-group h3:first-child {
22-
margin-top: 0;
23-
}
24-
</style>
25-
@endpush
26-
2710
@if ($crud->getFieldsWithoutATab()->filter(function ($value, $key) { return $value['type'] != 'hidden'; })->count())
2811
<div class="card">
2912
<div class="card-body row">
@@ -66,3 +49,32 @@ class="nav-link {{ isset($tabWithError) ? ($tab == $tabWithError ? 'active' : ''
6649
</div>
6750
</div>
6851

52+
@push('crud_fields_styles')
53+
<style>
54+
.nav-tabs-custom {
55+
box-shadow: none;
56+
}
57+
.nav-tabs-custom > .nav-tabs.nav-stacked > li {
58+
margin-right: 0;
59+
}
60+
61+
.tab-pane .form-group h1:first-child,
62+
.tab-pane .form-group h2:first-child,
63+
.tab-pane .form-group h3:first-child {
64+
margin-top: 0;
65+
}
66+
67+
/*
68+
when select2 is multiple and it's not on the first displayed tab the placeholder would
69+
not display correctly because the element was not "visible" on the page (hidden by tab)
70+
thus getting `0px` width. This makes sure that the placeholder element is always 100% width
71+
by preventing the select2 inline style (0px) from applying using !important
72+
*/
73+
.select2-container,
74+
.select2-container li:only-child,
75+
.select2-container input:placeholder-shown {
76+
width: 100% !important;
77+
}
78+
</style>
79+
@endpush
80+

0 commit comments

Comments
 (0)