File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,12 @@ const generateSelect = (target) => {
30
30
// add custom select options
31
31
const options = e . querySelectorAll ( 'option' ) ;
32
32
for ( let i = 0 ; i < options . length ; i ++ ) {
33
- let html = `<li value='${ options [ i ] . value } '>${ options [ i ] . innerText } </li>` ;
33
+ let html = `<li class=' ${ options [ i ] . selected && 'current' } ' value='${ options [ i ] . value } '>${ options [ i ] . innerText } </li>` ;
34
34
e . parentNode . querySelector ( '.options' ) . innerHTML += html ;
35
35
}
36
36
37
37
//add options and label
38
- e . parentNode . querySelector ( '.label' ) . innerHTML = e . getAttribute ( 'aria-placeholder' ) || 'select' ;
38
+ e . parentNode . querySelector ( '.label' ) . innerHTML = options [ 0 ] . innerHTML ;
39
39
40
40
}
41
41
@@ -58,6 +58,11 @@ const generateSelect = (target) => {
58
58
e . closest ( ".select" ) . querySelector ( '.label' ) . innerHTML = e . innerHTML ;
59
59
e . closest ( ".select" ) . classList . remove ( 'active' ) ;
60
60
e . closest ( ".select" ) . querySelector ( 'select' ) . value = e . getAttribute ( "value" ) ;
61
+ let siblings = e . closest ( ".select" ) . querySelectorAll ( '.options li' )
62
+ for ( s of siblings ) {
63
+ s . classList . remove ( 'current' )
64
+ }
65
+ e . classList . add ( 'current' )
61
66
} ) ;
62
67
} ) ;
63
68
You can’t perform that action at this time.
0 commit comments