@@ -18,15 +18,8 @@ const selectTypes = {
18
18
tagsSelect,
19
19
} ;
20
20
21
- // eslint-disable-next-line max-statements
21
+ // eslint-disable-next-line max-statements, complexity
22
22
function setupSelect ( el ) {
23
- const emptyOption = el . querySelector ( 'option[value=""]' ) ;
24
- if ( ! emptyOption ) {
25
- el . insertAdjacentHTML ( 'afterbegin' , '<option value=""></option>' ) ;
26
- }
27
- el . querySelector ( 'option[value=""]' ) . dataset . placeholder = true ;
28
-
29
- el . style . width = el . dataset . width ;
30
23
let settings = {
31
24
select : el ,
32
25
settings : {
@@ -35,6 +28,31 @@ function setupSelect(el) {
35
28
} ,
36
29
} ;
37
30
31
+ const selectStyles = window . getComputedStyle ( el ) ;
32
+ el . style . width = el . dataset . width ;
33
+ el . style . fontSize = selectStyles . fontSize ;
34
+
35
+ const searchSelectFilter = el . closest ( '.filter_form_field' ) ;
36
+ if ( searchSelectFilter ) {
37
+ if ( searchSelectFilter . classList . contains ( 'search_select_filter' ) ||
38
+ searchSelectFilter . classList . contains ( 'filter_string' ) ) {
39
+ settings . settings . allowDeselect = false ;
40
+ }
41
+
42
+ if ( el . options . length > 0 ) {
43
+ el . style . width = el . dataset . width || selectStyles . width ;
44
+ if ( selectStyles . display === 'inline-block' ) {
45
+ el . style . display = 'inline-flex' ;
46
+ }
47
+ }
48
+ }
49
+
50
+ const emptyOption = el . querySelector ( 'option[value=""]' ) ;
51
+ if ( ! emptyOption ) {
52
+ el . insertAdjacentHTML ( 'afterbegin' , '<option value=""></option>' ) ;
53
+ }
54
+ el . querySelector ( 'option[value=""]' ) . dataset . placeholder = true ;
55
+
38
56
Object . keys ( selectTypes ) . forEach ( ( type ) => {
39
57
if ( selectTypes [ type ] . classes . some ( ( className ) => el . classList . contains ( className ) ) ) {
40
58
settings = merge ( { } , settings , selectTypes [ type ] . settings ( el ) ) ;
@@ -44,8 +62,8 @@ function setupSelect(el) {
44
62
}
45
63
} ) ;
46
64
47
- const slim = new SlimSelect ( settings ) ;
48
- el . dataset . slimSelectId = slim . settings . id ;
65
+ // eslint-disable-next-line no- new
66
+ new SlimSelect ( settings ) ;
49
67
}
50
68
51
69
function initSelects ( node = document ) {
0 commit comments